<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/common/taglibs.jsp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>直播打点工具</title>
    <meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
    <meta http-equiv="Cache-Control" content="no-store"/>
    <meta http-equiv="Pragma" content="no-cache"/>
    <meta http-equiv="Expires" content="0"/>
	<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
	<link href="${ctx}/bootstrap/css/bootstrap.min.css" rel="stylesheet" />
	<link href="${ctx}/bootstrap/css/jquery-ui.css" rel="stylesheet" />
	<link href="${ctx}/bootstrap/css/common.css" rel="stylesheet" />
	<script src="${ctx}/bootstrap/js/jquery.min.js"></script>
	<script src="${ctx}/bootstrap/js/bootstrap.min.js"></script>
	<script src="${ctx}/bootstrap/js/tips.js"></script>	
	<script src="${ctx}/bootstrap/js/jquery-ui.js"></script>
	<script src="${ctx}/bootstrap/js/jquery-ui-timepicker-addon.js"></script>
	<script src="${ctx}/js/swfobject.js"></script>
	<!--[if IE]>
	<script src="${ctx}/bootstrap/js/respond.js"></script>
	 <![endif]-->
	 <style type="text/css">
	  
		 /* 日期样式 */
		 .ui-timepicker-div .ui-widget-header { margin-bottom: 8px; }
		.ui-timepicker-div dl { text-align: left; }
		.ui-timepicker-div dl dt { float: left; clear:left; padding: 0 0 0 5px; }
		.ui-timepicker-div dl dd { margin: 0 10px 10px 25%; }
		.ui-timepicker-div td { font-size: 90%; }
		.ui-tpicker-grid-label { background: none; border: none; margin: 0; padding: 0; }

		.ui-timepicker-rtl{ direction: rtl; }
		.ui-timepicker-rtl dl { text-align: right; padding: 0 5px 0 0; }
		.ui-timepicker-rtl dl dt{ float: right; clear: right; }
		.ui-timepicker-rtl dl dd { margin: 0 45% 10px 10px; }
	 
	 
		p.spe:hover{background-color:#fefefe;color:#000000}
		img{padding:8px;z-index:100;width:120px;height:80px}
		.relative{position:relative}
		.absolute{position:absolute}
		 
		 /* 自动拆条交替色 */
		.c999{background-color:#999999;}
		.cfff{background-color:#fff;}
		
		/* 自动拆条选中色 */
		.c09f{background-color:#003F82;}
		
		/* 自动拆条提交色 */
		.bcgreen{background-color:#804041;}

		/* 自动拆条广告提交色 */
		.bcred{background-color:#F0E1B6;}		
		
		/* 入点出点颜色 */
		.background-blue {background-color:blue;}
		.background-red  {background-color:red;}
		
		.c000{background-color:#000;}
		
		
		.fp_time{top:55px;right:8px;font-size:12px;background-color:#050708;opacity:0.7;width:104px;text-align:right;padding-right:10px}
		.fp_time2{bottom:28px;right: 8px;font-size: 12px;background-color: #050708;opacity: 0.7;width: 264px;text-align:right;padding-right:10px}
		.col-md-7 {width: 58.333333333333336%;}
		
		
		 /* 广告头 标识部分 */
		.transparent_class {
		filter:alpha(opacity=40);
		-moz-opacity:0.4;
		-khtml-opacity: 0.4;
		opacity: 0.4;

		border: 1px solid grey;
		position:absolute;
		top:0px;
		right:0px;
		width:100%;
		height:100%;
		display:block;
		}	
		
		.desc{position: absolute;top:40px;left:0px;font-size:12px;opacity:0.7;width:120px;}
		 
		
		
		 /* 页面结构调整 
        .lw{display:inline;width:475px;background-color:transparent;float:left;margin-left:-485px;margin-top:1px;}
		*/
         
		 
		 /* 拆条tab */
		.nav-tabs {

		padding:5px 0px 0px 3px;
		height:39px;
		border:1px solid #B2B2B2;
		border-bottom:1px solid #666666;
		background: #cccccc url("${ctx}/bootstrap/css/images/ui-bg_highlight-soft_75_cccccc_1x100.png") 50% 35% repeat-x;
		color: #222222;
        }
		.nav-tabs>li{margin-bottom:0px;}
			
		/*	
		padding-left:20px;
		border-bottom: 1px solid #B2B2B2;background-color:#428BCA;
		*/
		


		.nav-tabs>li.active>a, .nav-tabs>li.active>a:hover, .nav-tabs>li.active>a:focus {
		color: #09F;
		font-weight: bold;
		background-color: #fff;
		border: 1px solid #666666;
		border-bottom-color: transparent;
		cursor: default;
		}


		.nav-tabs>li>a {
		color:#333;
		line-height:1;
			}
		.nav>li>a{
			padding:7px 10px;
			height:33px;
			
		}
			

		.nav-tabs>li>a:hover {
		color:#09F;
		background-color: #fff;
		border-bottom-color: transparent;
			
			}
		
		
		.transparent{
				filter:alpha(opacity=80);
				-moz-opacity:0.8;
				-khtml-opacity: 0.8;
				opacity: 0.8;
		}
		
		.layout {
			position: absolute;
			left: 4%;
			top: 12%;
			z-index: 120;
			width: 30%;
			height:52%;
			font-size:12px;
		}
		
		.fragment-l{background-color:green;padding-top:12px;
		}
		.fragment-r{left:70%;background-color:green;padding-top:12px;
		}
		
		.ad-l{background-color:red;		
		}
		
		
		.ad-r{left:70%;background-color:red;
		}
		
		
		.btn-grey{background-color:#eee;}
		
		.btn-666{background-color:#666666;color:#fff;}
		.btn-666:hover,.btn-666:focus,.btn-666.focus,.btn-666:active,.btn-666.active{background-color:#363636;border-color:#222;color:#fff;}
		
		.input-sm{padding:0px;}
		
		
		.datetimepicker-dropdown-bottom-right:before {
		  right:176px;
		}
		
		.datetimepicker-dropdown-bottom-right:after {
		  right:177px;
		}
		
       /*  2015/3/4 
       
	    布居
	   */
		.row{margin:0;}

	    body{background:#fcfcfc;padding:10px;}
		 
		.cont,.left-panel{float:left;}
		.cont{width:100%;}
		.main{margin-left:510px;}
		.left-panel{margin-left:-100%;width:500px;}		
		
		
		.rt{border:1px solid #B2B2B2;border-top:none;margin:0px;padding:4px;padding-left:20px;padding-top:8px;background-color:#fff;}
		.rb{overflow-y:scroll;padding-left:5px;border:1px solid #B2B2B2;background-color:#000;}
		.right{margin-top:0px;}
		.tab-content{overflow-x:hidden;overflow-y:scroll;}
		.lb{border:1px solid #B2B2B2;border-top:none;padding-top:15px;margin:0px;background-color:#fff;}		
		
		.lc{height:300px;width:100%;background-color:#000;border:1px solid #B2B2B2;border-top:none;margin:0px;margin-bottom:10px;z-index:0;}

		
         /*拆条列表*/
		.segmentation{position:fixed;width:100%;bottom:0px;left:0px;z-index: 9999;}

		.segmentation .title{margin-left:80%;padding:1px 6px 1px 6px;font-weight:bold;background-color#fff;color:#09F;border:2px solid #09F;
							border-radius:8px;
							border-bottom-left-radius:0px;
							border-bottom-right-radius:0px;
							border-bottom:0px;
							margin-bottom:-2px;
							box-shadow:0 -1px 1px #888;
							}

		.segmentation .list{overflow-y:scroll;width:100%;height:400px;z-index:9999;display:none;background-color:#fff;border-top:2px solid #09F;box-shadow:0 0 5px #888}
        
		/*拆条tab ext*/
		.tabbable{position:relative;}
		.nav-opt{position:absolute;top:8px;left:250px;font-size:10px;}
		.nav-opt>button{color:#999;padding:1px 2px;box-shadow:inset 0 0 1px 1px #fff;border-radius:3px;}
		
		.nav-opt-enable{border:1px solid #707070;}
		button.nav-opt-enable{color:#333;}
		
		
		/* table */
		.table{margin-top:-5px;}
		
		.table-hover>tbody>tr:hover>td,.table-hover>tbody>tr:hover>th{background-color: #CDE6F7;}
		
		.inner-table {font-size:10px;width:100%}

		.inner-table input,.inner-table select{width:51px;font-weight:400;
			border-left:1px solid #E2E3EA;
			border-top:1px solid #ABADB3;
			border-bottom:1px solid #E3E9EF;
			border-right:1px solid #DBDFE6;
			border-radius:2px;
			margin-left:6px;}
		
		
		.remove-style input{width:51px;font-weight:400;
			border:1px solid transparent;
			background-color:transparent;
			margin-left:6px;}

		.remove-select-style{border:none;overflow:hidden;display:block;float:right;margin-right:3px;width:56px;}
		.remove-select-style select{margin:-2px -18px -2px -2px;width:75px;background-color:transparent;}		
		
	   .inner-table span{font-weight:bold;}
	   
		.modify-space td{padding-top:7px;}
		.modify-space a{cursor:pointer;text-decoration:underline;}
		.cblue{color:#2E8DED;}
		.cred{color:#C30;}
		.w10p{width:7%;}
		.w18p{width:18%;}


	.table>thead>tr>th, .table>tbody>tr>th, .table>tfoot>tr>th, .table>thead>tr>td, .table>tbody>tr>td, .table>tfoot>tr>td{border-top:0px;border-bottom:1px solid #fff;}
	.table-striped>tbody>tr:nth-child(odd)>td, .table-striped>tbody>tr:nth-child(odd)>th{background-color:#F2F2F2;}
	
	/* 表单样式处理 */
	.rt label,#cForm label,#dForm label{font-weight:normal;font-size:12px;margin:0;padding:0;}
	
	.rt input,.rt div,#cForm div,#dForm div{margin:0;padding:2px 0px;}
	 #ocr,#acr{width:90px;margin-top:5px;}
	 #submitStartTime{margin-left:5px;}
	 .date{width:122px;display:inline-block;}
	 .switch{
			display: inline-block;
			margin-bottom: 0;
			vertical-align: middle;
			cursor: pointer;

			-webkit-user-select: none;
			-moz-user-select: none;
			-ms-user-select: none;
			-o-user-select: none;
			
			width:61px;height:26px;margin-right:15px;		 

			background: #fff url("${ctx}/bootstrap/css/images/switch.png") 0 -2px;
			}
	.switch-position{background-position:0 27px;}
	
	.album-pop{position:absolute;right:4px;top:21px;z-index:10;background-color:#468847;width:91%;padding:10px;color:#ffffff;display:none}
	
	 /*出入点标识*/
	.in-out-mark-s{width:40px;top:8px;height:63px;background-color:#4CD74C;padding-top:10px;}
	.in-out-mark-b{height:194px;padding-top:60px;}
	.p-l{left:8px;}
	.p-l-48{left:48px;}
	.p-r{right:8px;background-color:#FF0000;}
	.p-r-48{right:48px;background-color:#FF0000;}
	.auto-seg-tips,.merg-seg-tips{color:#DADADA;text-align:center;font-size:32px;}
	
	.bdred{border-color:red;}
	.red {border: 1px solid #fff;}
	.videoName{width:420px;position:relative;z-index:99999;}
	</style>
</head>
<body>
	<script>
	$("body").hide();
	</script>

	<div class="alert alert-danger alert-dismissible fade in" role="alert" style="text-align:center;display:none;"></div>

    <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
    <div class="modal-content">
    <div class="modal-header">
    <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
    <h4 class="modal-title" id="myModalLabel"></h4>
    </div>
    <div class="modal-body" id="radio-title-list">
    
    </div>
    <div class="modal-footer">
    <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
    <button type="button" class="btn btn-primary  identification" data-dismiss="modal">确定</button>
    </div>
    </div>
    </div>
    </div>		

<div class="row">
	<div class="cont">

		<div class="main">

		  <!-- 右下打点图片 start -->
		  <div class="rb right img-content" id="makedImg">

		  </div>
			<!-- 右下打点图片 end -->		
		
		<div class="rt">

			<form class="form-horizontal">
			  <div class="form-group" style="margin:0;padding:0;margin-bottom:5px;">
				
				<div class="col-sm-3" style="width:165px;">
				<label class="control-label">起始:</label>
				  <input type="text" class="form-control date input-sm"id="inputStartTime" />
				</div>
				
				<div class="col-sm-3"  style="width:165px;">
				<label class="control-label">结束:</label>
				  <input type="text" class="form-control date input-sm" id="inputEndTime" />
				</div>
				<div class="col-sm-4" style="width:365px;">
					<a class="btn btn-default btn-sm" id="submitStartTime">确定</a>

					<!--// 3.04版本去除自动拆条 
					自动拆条
					<a class="switch" action-name="auto-segmentation"></a>	
					   // end -->

				<div class="btn-group btn-group-sm" role="group">
					<a class="btn btn-default" id="changeBigPic">大图</a>
					<a class="btn btn-default btn-primary" id="changeSmallPic">小图</a>
					</div>
					<a class="btn btn-success btn-sm" style="margin-left:13px;width:57px;color: #fff;background-color: #47a447;border-color: #398439;" id="picNum">0</a>
				

					
										
			  </div>					

			
			  </div>
			</form>

			<form class="form-inline" role="form">
			  <div class="checkbox">
				<label>
				  <input type="checkbox" id="autoRunPic"> 自动滚动图片
				</label>
			  </div>
	
			  <div class="form-group">
				<select class="form-control input-sm" name="jumpType">
				  <option value="1">跳转时间点</option>
				  <option value="2">跳转帧</option>
				</select>
			  </div>
			  <div class="form-group">
					<input type="text" class="form-control input-sm" id="jumpContent" style="width:134px;margin-right:13px;" value="00:00:00">
			  </div>
			  <button type="button" class="btn btn-default btn-sm" id="jumpSubmit">确定</button>
			  
			  <div class="form-group" style="width:170px;">
					<div style="display:none;float:left;">
					背景颜色
					<a action-name="switch" class="switch switch-position"></a>
					</div>
					
					<a id="alert-pop" style="float:left;" class="btn  btn-default btn-sm" data-toggle="modal" data-target="#myModal">定时提醒</a>	

					<a id="help-pop" style="float:right;" class="btn  btn-default btn-sm" data-toggle="modal" data-target="#myModal">打点系统帮助</a>						
			  </div>
			  
			  
		  
			  
			</form>

		</div> <!-- 右上测查询 end -->
		
	
		</div>
		
	</div><!-- end cont -->	



  <div class="left-panel">

    

	<!-- 左中侧播放器 START -->
  	<div class="movie lc">
  		<div id="ppsLiveDiv">
		</div>
  	</div> <!-- 左中侧播放器 end -->

    <!-- 左下侧提交 start -->
    <div class="row" style="margin:0px;background-color:#E4E4E4;">
    <div class="tabbable">
        <ul class="nav nav-tabs">
            <li class="active"><a href="#tab1" data-toggle="tab" action-name="segmentation-params-tab">拆条参数</a></li>
			<!--// 3.0.4注释
			<li><a href="#tab2" data-toggle="tab" action-name="auto-segmentation-tab">自动拆条</a></li>
			<li><a href="#tab3" data-toggle="tab" action-name="merge-segmentation-tab">合并拆条</a></li>
			//-->
        </ul>
		<!--// 3.0.4注释
		<div class="nav-opt">
			<input type="checkbox" action-name="select-all" />全选&nbsp;&nbsp;&nbsp;
			<button class="sub-seg ui-corner-all ui-state-hover" action-name="sub-all-seg">提交拆条</button>
			<button class="sub-adv ui-corner-all ui-state-hover" action-name="sub-all-ad">提交广告</button>
			&nbsp;&nbsp;
			<button class="sub-seg ui-corner-all ui-state-hover" action-name="sub-all-merge">合并</button>
			<button class="sub-adv ui-corner-all ui-state-hover" action-name="sub-all-del">删除</button>
		</div>
		//-->
        <div class="tab-content lb">
            <div class="tab-pane active" id="tab1">
              



                <form class="form-horizontal" id="cForm" style="width:240px;float:left;position:relative;border-right:1px dotted #B2B2B2">
				
				<div style="position:absolute;left:270px;top:200px;width:240px;font-size:12px;">
								
					<a class="btn btn-default btn-xs" id="" action-name="save-album-smart-library">专辑入智能库</a><br />
					<a class="btn btn-default btn-xs" action-name="save-ad-smart-library" style="margin-top:5px;margin-bottom:5px;" id="">广告入智能库</a><br /><br />
				
				
					<input type="radio" class="cVideo " name="videotype" value="-1" checked  /><span style="padding-right:10px;">创建新节目</span><br/>
					<input type="radio" class="cVideo " name="videotype" value="0" /><span style="padding-right:10px">选择未制作成片的节目</span><br/>
					<input type="radio" class="cVideo " data="cover-program" name="videotype" value="1" /><span>覆盖已制作成片的节目</span><br/><br/>
                   <!--
					<div id="">
						<input type="checkbox" name="enableClound"/>
						<label class="control-label">取消启用云转</label>

					</div>		
                   -->
					<div id="cover-program-cfm" style="display:none;">
						<input type="checkbox" name="reTranscodeConfirm"  />
						<label class="control-label">重转免确认</label>

					</div>	
					<a class="btn btn-default btn-xs disabled" id="ocr" data-toggle="modal" data-target="#myModal">OCR</a><br />
					<a class="btn btn-default btn-xs disabled" id="acr" data-toggle="modal" data-target="#myModal">ASR</a>				
				</div>
								
                <div class="form-group">

                <label class="col-sm-3 control-label">起点:</label>
                <div class="col-sm-8">
                <input type="text" class="form-control input-sm" name="sTime" />
                </div>
                </div>
				
				<div class="form-group">
					<label class="col-sm-3 control-label">终点:</label>
					<div class="col-sm-8">
					<input type="text" class="form-control input-sm" name="eTime" />
					</div>
                </div>

                <div class="form-group">
                <label class="col-sm-3 control-label">封面:</label>
                <div class="col-sm-8">
                <input type="text" class="form-control input-sm" name="imageId" />
                </div>
                </div>

                <div class="form-group">
					<label class="col-sm-3 control-label">频道:</label>
					<div class="col-sm-8">
					<input type="text" class="form-control input-sm" name="categoryName" />
					<input type="hidden" name="categoryId"/>
					<div class="cn_hide3" style="position:absolute;left:0px;top:33px;z-index:10;background-color:#468847;width:100%;padding:10px;color:#ffffff;display:none"></div>
					</div>
                </div>

                <div class="form-group">
					<label class="col-sm-3 control-label">标题:</label>
					<div class="col-sm-8" style="position:relative">
						<input type="text" class="form-control input-sm" name="videoName" />
						<span id="limit" style="font-size:10px;color:red;display:none;">标题长度不能超过43个字符</span>
						<input type="hidden" class="form-control input-sm" name="videoId" />
						<div class="cn_hide" style="left:15px;top:33px;z-index:10;background-color:#468847;width:90%;padding:10px;color:#ffffff;display:none"></div>
					</div>
                </div>
				
                <div class="form-group">
                <label class="col-sm-3 control-label">专辑:</label>
                <div class="col-sm-8" style="position:relative">
                <input type="text" class="form-control input-sm" name="albumName" disabled="disabled"/>
                <input type="hidden" class="form-control input-sm" name="albumId" />
                <div class="cn_hide2" style="position:absolute;left:15px;top:33px;z-index:10;background-color:#468847;width:91%;padding:10px;color:#ffffff;display:none"></div>
                </div>
                </div>

				<div class="form-group">
					<label class="col-sm-3 control-label">优先级:</label>
					<div class="col-sm-8" style="font-size:12px;">
						<input type="radio" name="priority" value="3">紧急
						<input type="radio" name="priority" value="2">高
						<input type="radio" name="priority" value="1">中
						<input type="radio" name="priority" value="0" checked="checked">低
					</div>
                </div>

				<div class="form-group">
					<label class="col-sm-3 control-label">分辨率:</label>
					<div class="col-sm-8" style="font-size:12px;">
						<input type="radio" name="video_dpi" value="" checked="checked">原有比例
						<input type="radio" name="video_dpi" value="16x9">16:9
						<input type="radio" name="video_dpi" value="4x3">4:3
					</div>
                </div>
				
				
				<div class="form-group">
                <label class="col-sm-3 control-label">描述:</label>
				<div class="col-sm-8">
				<textarea class="form-control  input-sm" rows="3" name="desc" eut=""></textarea>
				</div>
                </div>
				
				<div class="form-group">
					<label class="col-sm-3 control-label">合作方:</label>
					<div class="col-sm-8">
					<select id="cp" class="form-control input-sm">
					</select>
					</div>
                </div>
				
                <div class="form-group">
				<label class="col-sm-3 control-label"></label>
                <div class="col-sm-8">
				<a class="btn btn-success btn-sm" id="reviewInfo">预览</a>
				<a class="btn btn-primary btn-sm" id="addInfo">提交</a>
				<!--<a class="btn btn-default btn-sm" onclick="FFSumbit();">提交已表示帧入库</a>-->

				</div>
                </div>
				
				
				
				
                </form>
        

			<form class="form-horizontal" id="dForm" style="width:240px;float:left;">
			  <div class="form-group">
				<label class="col-sm-3 control-label">起点:</label>
				<div class="col-sm-8">
				  <input type="text" class="form-control input-sm" name="d_sTime" />
				</div>
			  </div>
			  <div class="form-group">
				<label class="col-sm-3 control-label">终点:</label>
				<div class="col-sm-8">
				  <input type="text" class="form-control input-sm" name="d_eTime" />
				</div>
			  </div>
			  <div class="form-group">
				<label class="col-sm-3 control-label">标题:</label>
				<div class="col-sm-8">
					<input type="text" class="form-control input-sm" name="d_videoName" value="广告" />
				</div>
			  </div>


                <div class="form-group" style="margin-top:10px">
				<label class="col-sm-3 control-label"></label>
                <div class="col-sm-8"><a class="btn btn-success btn-sm" id="d_reviewInfo">预览</a><a style="margin-left:4px;" class="btn btn-primary btn-sm" id="d_addInfo">提交</a></div>
                </div>

			</form>


            </div>

            <div class="tab-pane" id="tab2">
					<table class="table table-striped table-hover">
						  <tbody>
						   <tr>
						   </tr>
						  </tbody>
					</table>
					<div class="auto-seg-tips" >当前没有自动拆条信息</div>
            </div>
			
			
			

            <div class="tab-pane" id="tab3">
					<table class="table table-striped table-hover">
						  <tbody>
						    <tr>
							</tr>
						  </tbody>
					</table>
					<div class="merg-seg-tips">当前没有合并信息</div>
            </div>			
				
        </div>

    </div>


	</div><!-- 左下form end -->
  </div>



</div>


<!-- 底部拆删条信息 start -->
<div class="row segmentation">

	<div class="title btn btn-default btn-xs" action-name="segmentation">拆条列表<span id="list-slide-shrink">展开</span> <span class="glyphicon glyphicon-chevron-up" aria-hidden="true"></span></div>
	<div class="list" data-show="false">

		<div class="col-sm-6" id="home">
			<h3 style="font-weight: 700;margin-bottom:0px;font-family: '微软雅黑';">拆条列表</h3>
			<table class="table table-striped" style="margin-top:5px;">
				<thead>
					<tr style="background-color:#666666;color:#fff">
						<th>序号</th>
						<th>入点</th>
						<th>出点</th>
						<th>标题</th>
						<th>频道</th>
						<th>专辑</th>
						<th>封面</th>
						<th>状态</th>
						<th>操作</th>
					</tr>
				</thead>
				<tbody id="showInfo1">
				</tbody>
			</table>
		</div>
		<div class="col-sm-6" id="settings">
			<h3  style="font-weight: 700;margin-bottom:0px;font-family: '微软雅黑';">广告列表</h3>
			<table class="table table-striped" style="margin-top:5px;">
				<thead>
					<tr style="background-color:#666666;color:#fff">
						<th>序号</th>
						<th>入点</th>
						<th>出点</th>
						<th>标题</th>
						<th>状态</th>
						<th>操作</th>
					</tr>
				</thead>
				<tbody id="showInfo2">
				</tbody>
			</table>
		</div>
	</div>
	
</div>

<!--单张图片视频预览 start-->
<div class="popover fade left in" id="play-one" role="tooltip" style="display:block;top:-1000px;left-1000px;width:140px;height:105px;background-color:#000;border:1px solid #fff;">
	<div class="arrow" style="top: 50%;"></div>
	<div class="popover-content" id="ppsLiveOneFrame"></div>
</div>
<!--单张图片视频预览 end-->

<!--裁剪精确度 start-->
<div class="popover fade left in" id="accurateStartEndOutDiv" role="tooltip" style="position:fixed;display:block;top:-10000px;left:-10000px;max-width:100%;width:100%;height:100%;background-color:#fff;">
	     <div class="modal-header">
	    <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true" id="ase-close">&times;</span><span class="sr-only">关闭</span></button>
        <h6 class="modal-title">裁剪精确度</h6>
      </div>
	
	<div class="popover-content" id="accurateStartEndDiv"></div>
</div>
<!--裁剪精确度 end-->

<div id="taskid" style="display:none"></div>
<div id="lastImg" style="display:none">0</div>
<div id="lastCate" style="display:none">0</div>
<div id="allList" style="display:none"></div>
<div id="noneData" style="display:none"></div>
<div id="picWH" style="display:none"></div>
<div id="isOver" style="display:none">1</div>
<div id="userId" style="display:none">${user.id}</div>
<div id="userName" style="display:none">${user.name}</div>
<div id="storage-data" style="display:none"></div>
<script type="text/javascript">
var statisticOcrTitle = "";
var timer = null;
var playOnePosition = {
	left : '',
	top : ''
};

var index = 1, stime = 0, etime = 0, pic = 0, taskid = 0, lastImg = 0, linePicNum = 9;
var isStart = false;
var delList = [];
var subData = [];
var needDatas = [];
var period = '';
var smallPic = true;
var lb = 1;
var error = '';
var today = '';
var isClicked = false;
var isSetFpTime = false;
var firstFpTime = 0;
var fpTime = 'fp_time';
var channelInfo = [];


//取浏览器参数
url = window.location.href;

 var queryStringArr = location.search.match(new RegExp("[\?\&][^\?\&]+=[^\?\&]+","g")),
	 queryStringObj = {}
	 itemArr = [];

try{
 for(var i = 0; i < queryStringArr.length; i++){
		
	   itemArr = queryStringArr[i].substring(1).split("=");
		
	  if(i==0)
	  {
		  queryStringObj['channel_code'] = itemArr[0];
		  queryStringObj['ip'] = itemArr[1];
	  }
	  else
	  {
		  queryStringObj[itemArr[0]] = itemArr[1];
	  }
 }
}
catch(e){
	
	//alert("URL地址参数有误，请确认！");
	live.tips("error","URL地址参数有误，请确认！");
	//console.log(e.message);
}

var channel_name = queryStringObj['channel_code'],
	ip = queryStringObj['ip'],
	freeType = queryStringObj['free_type'],
	_channel_id = queryStringObj['channel_id'];
	_channel_name_str= queryStringObj['cn'];

if (!channel_name) {
	error = '系统错误:收录频道代号为空!';
	//alert(error);
	live.tips("error",error);
}
if (!ip) {
	error = '系统错误:收录ip地址为空!';
	//alert(error);
	live.tips("error",error);
}
var dotUrl = 'http://' + ip + ':8080/dot/dodot',
adUrl = 'http://' + ip + ':8080/dot/doadstore', // 广告入库学习
listUrl = 'http://' + ip + ':8080/dot/json',
initUrl = 'http://' + ip + ':8080/dot/init',
cateUrl = 'http://' + ip + ':8080/dot/cate',
sty2Url = 'http://' + ip + ':8080/dot/sty2',
ocrUrl = 'http://' + ip + ':8080/dot/ocr',
acrUrl = 'http://' + ip + ':8080/dot/acr',
channelInfoUrl = 'http://' + ip + ':8080/channel/channelinfo';

$('.date').datetimepicker({
	timeFormat : 'HH:mm:ss',
	stepHour : 1,
	stepMinute : 1,
	stepSecond : 1
});

$(".cVideo").click(function () {
	if ($(this).attr('data') == 'cover-program') {
		$("#cover-program-cfm").show();
	} else {
		$("#cover-program-cfm").hide();
	}
});
function validStart() {
	s_time = $('#inputStartTime').val();
	e_time = $('#inputEndTime').val();
	if (!s_time.length) {
		//alert('请先输入起始时间');
		live.tips("error",'请先输入起始时间');
		return false;
	}
	if (!e_time.length) {
		//alert('请先输入结束时间');
		live.tips("error",'请先输入结束时间');
		return false;
	}
	if (!isDateTime(s_time)) {
		//alert('起始时间格式不正确!');
		live.tips("error",'起始时间格式不正确!');
		return false;
	}
	if (!isDateTime(e_time)) {
		//alert('结束时间格式不正确!');
		live.tips("error",'结束时间格式不正确!');
		return false;
	};
	sUnix = dateToUnix(s_time);
	eUnix = dateToUnix(e_time);
	period = eUnix - sUnix;
	if (period < 0) {
		//alert('开始时间不能大于结束时间');
		live.tips("error",'开始时间不能大于结束时间');
		return false;
	}
	if (period == 0) {
		//alert('开始时间不能等于结束时间');
		live.tips("error",'开始时间不能等于结束时间');
		return false;
	}
	timestamp = Date.parse(new Date());

	if ((sUnix * 1000) > timestamp) {
		//alert('开始时间不能大于当前时间');
		live.tips("error",'开始时间不能大于当前时间');
		return false;
	}
	today = s_time.replace(/-/g, '').substring(0, 8);
	return sUnix;
}
function getLineWidth() {
	lineWidth = $('.img-content').width();
	picWidth = $('.relative').width();
	linePicNum = parseInt(lineWidth / picWidth);
}
function dateToUnix(d) {
	var tmp_datetime = d.replace(/:/g, '-');
	tmp_datetime = tmp_datetime.replace(/ /g, '-');
	var arr = tmp_datetime.split("-");
	var now = new Date(Date.UTC(arr[0], arr[1] - 1, arr[2], arr[3] - 8, arr[4], arr[5]));
	return parseInt(now.getTime() / 1000);
}

function validAddInfo(data) {
	v = true;
	$.each(data, function (message, type) {
		if (!type.length) {
			//alert(message + '不存在，请重新输入');
			live.tips("error",message + '不存在，请重新输入');
			v = false;
			return false;
		}
	});
	return v;
}

function isDateTime(strDateTime) {
	// 先判断格式上是否正确
	var regDateTime = /^(\d{4})-(\d{1,2})-(\d{1,2}) (\d{1,2}):(\d{1,2}):(\d{1,2})$/;
	if (!regDateTime.test(strDateTime))
		return false;
	return true;
}
function isJumpData(data, type) {
	if (type == 1) {

		regJumpData = /^(\d{2}):(\d{2}):(\d{2})$/;
		if (!regJumpData.test(data)) {
			return false;
		}
		return true;
	} else {
		if (isNaN(data)) {
			return false;
		}
		return true;
	}
}

function fromLIstJump(index) {
	if (!isJumpData(index, 0)) {
		//alert('跳转输入格式错误');
		live.tips("error",'跳转输入格式错误');
		return false;
	}
	var jumpContent = index + '-jump';
	if ($('.relative').hasClass(jumpContent)) {
		$('#makedImg').scrollTop(0)
		sTop = $('.' + jumpContent).offset().top - 100;
		$('#makedImg').scrollTop(sTop);
	} else {
		//alert('没有这帧');
		live.tips("error",'没有这帧');
	}
}

function addInfo(data, type) {

	if (type == 'add') {
		html = '<tr class="scorll-to-frame" frame-index="' + data.index + '"><td>' + data.index + '</td><td>' + data.sTime + '</td><td>' + data.eTime + '</td><td><div style="padding:0;margin:0;width:124px;overflow:hidden;white-space: nowrap;" title="' + data.title + '">' + data.title + '</div></td><td>' + data.channel + '</td><td>' + data.album + '</td><td>' + data.pic + '</td><td>已生成</td><td><button class="btn btn-info" id="del-' + data.index + '" onclick="if( confirm(\'确认要删除吗?\')){$(this).parent().parent().remove();delOne(\'打点\',\'' + data.sTime + '\',\'' + data.eTime + '\');}">删除</button><a style="margin-left:5px;" onClick="reviewOne(\'' + data.sTime + '\',\'' + data.eTime + '\',\'打点\');" class="btn btn-success">预览</a><a style="margin-left:5px;" onClick="fromLIstJump(\'' + data.sTime + '\');" class="btn btn-success">跳转</a></td></tr>';
		$('#addInfo').html('成功');
		$('#showInfo1').append(html);
	} else {
		html = '<tr class="scorll-to-frame" frame-index="' + data.index + '"><td>' + data.index + '</td><td>' + data.sTime + '</td><td>' + data.eTime + '</td><td><div style="padding:0;margin:0;width:124px;overflow:hidden;white-space: nowrap;" title="' + data.title + '">' + data.title + '</div></td><td>已生成</td><td><button class="btn btn-info" id="del-' + data.index + '" onclick="if( confirm(\'确认要删除吗?\')){$(this).parent().parent().remove();delOne(\'删除\',\'' + data.sTime + '\',\'' + data.eTime + '\');}">删除</button><a style="margin-left:5px;" onClick="reviewOne(\'' + data.sTime + '\',\'' + data.eTime + '\',\'删除\');" class="btn btn-success">预览</a><a style="margin-left:5px;" onClick="fromLIstJump(\'' + data.sTime + '\');" class="btn btn-success">跳转</a></td></tr>';
		$('#d_addInfo').html('成功');
		$('#showInfo2').append(html);
		for (i = parseInt(data.sTime); i <= data.eTime; i++) {
			delList.push(i);
		}
		uniqueArr = [];
		$.each(delList, function (i, el) { //去重复
			if ($.inArray(el, uniqueArr) === -1)
				uniqueArr.push(el);
		});
		delList = uniqueArr;
	}
}
function review() {
	if (!subData.length) {
		//alert('请先打点,再预览!');
		live.tips("error",'请先打点,再预览!');
		return false;
	}
	var reviewData = {
		'list' : []
	};
	//console.log(subData);
	$.each(subData, function (k, v) {
		src = $('#img-' + v).attr('src');
		if (!src) {
			//alert('数据为空不能预览!');
			return false;
		}
		flv = '{"url":"';
		flv += src.replace(/jpg/g, "flv");
		flv += '","name":"';
		flv += k;
		flv += '"}';
		obj = eval('(' + flv + ')');
		reviewData.list.push(obj);
	})

	playAll(reviewData);

}
//打好的点预览
function reviewOne(s, e, vType) {
	var reviewOneData = {
		'list' : []
	};
	s = parseInt(s);
	e = parseInt(e);
	for (i = s; i <= e; i++) {
		if (delList.length && vType != "删除") {
			isNeed = true;
			for (j = 0; j <= delList.length; j++) {
				v = delList[j];
				if (i == v) {
					isNeed = false;
				}
			}
			if (isNeed) {
				src = $('#img-' + i).attr('src');
				flv = '{"url":"';
				flv += src.replace(/jpg/g, "flv");
				flv += '","name":"';
				flv += i;
				flv += '"}';
				obj = eval('(' + flv + ')');
				reviewOneData.list.push(obj);
			}
		} else {
			src = $('#img-' + i).attr('src');
			flv = '{"url":"';
			flv += src.replace(/jpg/g, "flv");
			flv += '","name":"';
			flv += i;
			flv += '"}';
			obj = eval('(' + flv + ')');
			reviewOneData.list.push(obj);
		}

	}
	//console.log(reviewOneData);
	playAll(reviewOneData);
}
//删除打好的点预览
function delOne(type, s, e) {
	arr3 = [];
	if (type == '删除' && delList.length) {
		$('#showInfo2').find('tr').each(function () {
			d_stime = parseInt($(this).children().eq(1).text());
			d_etime = parseInt($(this).children().eq(2).text());
			for (var i = d_stime; i <= d_etime; i++) {
				//console.log(i);
				arr3.push(i);
			}
		})
		uniqueArr3 = [];
		$.each(arr3, function (i, el) { //去重复
			if ($.inArray(el, uniqueArr3) === -1)
				uniqueArr3.push(el);
		});

		delList = uniqueArr3;
	}
}

//拆分数据
function splitData(stime, etime, needRemoveDelData) {
	stime = parseInt(stime);
	etime = parseInt(etime);
	subData = [];
	needDatas = [];
	for (i = stime; i <= etime; i++) {
		needDatas.push(i);
	}
	//console.log(needDatas);
	//console.log(delList);
	if (needRemoveDelData && delList.length) {
		$.each(delList, function (k, v) {
			v = parseInt(v);
			if (stime <= v && v <= etime) {
				for (var i = 0; i < needDatas.length; i++) { //删除v的元素
					if (needDatas[i] == v) {
						needDatas.splice(i, 1);
						break;
					}
				}
			}
		})
	}
	subData = needDatas;
	//console.log(subData);
}
//提交数据给刘志红
function postData(list, newPA, imageId, programId, addData) {
	sList = '[';
	$.each(list, function (k, v) {
		sList += v + ',';
	})
	sList = sList.substring(0, sList.length - 1); //去除逗号
	sList += ']';

	pData = {
		'title' : newPA.title,
		'categoryId' : newPA.cat,
		'albumId' : newPA.alb,
		'code' : channel_name,
		'programId' : programId,
		'userId' : $('#userId').text(),
		'from_client' : true,
		'key' : taskid,
		'list' : sList,
		'imageId' : imageId,
		'head' : accurateFrame.head,
		'end' : accurateFrame.end,
		'priority' : newPA.priority,
		'video_dpi' : newPA.video_dpi,
		'uid' : newPA.uid,
		'partnerId' : newPA.partnerId,
		'episodeType' : newPA.episodeType,
		'enableClound' : newPA.enableClound,
	};
	accurateFrame.head = '';
	accurateFrame.end = '';
	accurateFrame.endSetted = false;
	accurateFrame.headSetted = false;

	$.ajax({
		cache : false,
		async : false,
		type : "post",
		url : dotUrl,
		data : pData,
		success : function (data) {
			if (data.error != 0) {
				//alert(data.error);
				live.tips("error",data.error);
				return false;
			} else {
				$('#addInfo').html('成功');
				$('#cForm').find('input[type=text]').each(function () {
					if ($(this).attr('name') == 'albumName' || $(this).attr('name') == 'categoryName') {}
					else {
						$(this).val('');
					}

				});

				$('textarea[name=desc]').val('');
				addInfo(addData, 'add');
				index = index + 1;
				return true;
			}
		},
		dataType : "json",
		error : function () {
			//alert('编码服务器网络错误,请稍后再提交！');
			live.tips("error",'编码服务器网络错误,请稍后再提交！');
			$('#addInfo').removeAttr('disabled').html('提交');
		}
	});
	return true;
}
function addClearFix() {
	cb = 1;
	$('#makedImg').find('.text-center').each(function (k, v) {
		s = '<div class="clearfix breakWord">&nbsp;</div>';
		if (smallPic) {
			if (cb % linePicNum == 0) {
				$(this).after(s);
			}
		}
		if (!smallPic) {
			if (cb % linePicNum == 0) {
				$(this).after(s);
			}
		}
		cb++;
	})
}
function getDataByNum(_num) {
	var day = 864000,
	hour = 3600,
	minute = 60,
	base = 0,
	res = '',
	num = _num;
	if (num >= day) {
		base = parseInt(num / day);
		res += String(base);
		num = num - base * day;
	}
	if (num >= hour) {
		base = parseInt(num / hour);
		if (base < 10) {
			res += '0';
		}
		res += String(base);
		num = num - base * hour;
		res += ':';
	} else {
		res += '00:';
	}
	if (num >= minute) {
		base = parseInt(num / minute);
		if (base < 10) {
			res += '0';
		}
		res += String(base);
		num = num - base * minute;
		res += ':';
	} else {
		res += '00:';
	}
	if (num >= 0) {
		if (num < 10) {
			res += '0';
		}
		res += String(num);
	}
	return res;
}

$('#noneData').data({
	'id' : 0
});
//获取cate数据
function getCate() {
	if (taskid && isStart) {

		$.get(cateUrl, {
			'key' : taskid,
			'index' : 0,
			'type' : 1,
			'from_client' : true
		}, function (data) {
			cate_list = data.list;
			cate_i = 0;
			$.each(cate_list, function (cate_index, cate) {
				if (cate.video_list.length) {
					if (cate_i % 2 == 0) {
						$.each(cate.video_list, function (video_list_k, cate_Id) { //cate.type == 1;
							$('#cate-' + cate_Id).css('border-bottom', '1px solid red').attr('test', cate_i);
						})
					} else {
						$.each(cate.video_list, function (video_list_k, cate_Id) { //cate.type == 1;
							$('#cate-' + cate_Id).css('border-bottom', '1px solid yellow').attr('test', cate_i);
						})
					}
					cate_i++;
				}

			})

		}, 'json')
	}
}
var last_i = 0;    // 上次识的库索引
var adLibList = [];
var sty2Data = {};
var d_sty2Data =[];  // 广告头和尾

//获取cate数据
function getSty2() {
	if (taskid && isStart) {

		$.get(sty2Url, {
			'key' : taskid,
			'index' : 0,
			'offset' : 100,
			'from_client' : true
		}, function (data) {
			//adLibList = [];
			sty2Data = data;
			var ad_lib_list = data.list.splice(last_i);
			$.each(ad_lib_list,function (i,item){
				if(item.video_list[item.video_list.length-1] > parseInt($("#picNum").text(),10)-1 || item.video_list.length===0)
				{
					return;
				}
               
				last_i++;
				
				var drawUnderline = function(id,color){
							try{
								var html = '<div style="left:50%;position:absolute;width:50%;height:3px;border-bottom:3px solid '+color+';"></div>';
								$('#cate-'+id).append(html);
								
							}
							catch(e){ console.log(e.message);}				
				}
				
				if(item.type == VOD.CONFIG("adLibHead") || item.type == VOD.CONFIG("adLibTail"))
				{	
					$.each(item.video_list,function(j,id){	
						if($('#cate-'+id).attr("style")!=undefined)
							drawUnderline(id,'green');
						else
							$('#cate-'+id).css('border-bottom', '3px solid green');
					});
				}
				else if(item.type == VOD.CONFIG("adLib"))
				{
					if(item.video_list.length>0)
					adLibList.push({s:item.video_list[0],e:item.video_list[item.video_list.length-1]});
				
					var i = 0;
					var la = item.video_list.length;
					
					$.each(item.video_list,function(j,id){
		
						// 片头、片尾有广告再下划线双色标识
						if($('#cate-'+id).attr("style")!=undefined)
							drawUnderline(id,'red');
						else
						{
							$('#cate-'+id).css('border-bottom', '3px solid red');
						}
						i++;
					});					
				}
			});
		}, 'json');
	}
}

function nofind(img_url){  
	var img=event.srcElement;  
	img.src=img_url; 
}  

//获取json数据
function getData() {
	$('#addInfo,#d_addInfo').removeAttr('disabled').html('提交');
	isOver = $('#isOver').text();
	if (isOver == '0') {
		return false;
	}
	taskid = $('#taskid').html(); // init接口返回的直播taskid
	lastImg = $('#lastImg').html(); // 最后加载的图下
	if (taskid && isStart) {
		$('#isOver').text('0');
		$.ajax({
			type : "get",
			url : listUrl,
			data : {
				'key' : taskid,
				'from_client' : true,
				'index' : lastImg,
				'type' : 1,
				'offset' : 100,
			},
			success : function (data) {
				$('#isOver').text('1'); //防止并发
				if (data.list.length) {
					li = '';
					var sty = $('#picWH').html();

					$.each(data.list, function (i, value) {

						fp_time = value.fp;
						fp_pos = fp_time.lastIndexOf('/') + 1;
						fp_time = fp_time.substr(fp_pos, 10);
						if (!isSetFpTime) {
							firstFpTime = parseInt(fp_time);
							thisFpTime = '00:00:00';
						} else {
							tmpFpTime = (parseInt(fp_time) - firstFpTime);
							thisFpTime = getDataByNum(tmpFpTime);
						}
						//////////////////////////////////////////////////////////////////////////////////////////

						/*
						value.imgtype==0 普通图片
						value.imgtype==1 广告
						value.imgtype==2 片头
						 */
						//var s = generateMixed(1);
						//value.imgtype=s

						/*
						var state=1;
						var ly = '';


						if(value.imgtype==1)
					{
						ly=layer('ad');
						state=5;
						}
						else if(value.imgtype==2)
					{
						ly=layer('perspectiveImg');
						state=5;
						}

						var opt = identifyImgOpt(state);

						var desc = '';
						if(opt.desc!='')
						desc = '<div class="desc2">'+opt.desc+'</div>';


						bt='<div class="btn-group text-left" style="position:absolute;top:2px;right:0">'
						+'<button class="btn dropdown-toggle btn-default" data-toggle="dropdown" style="padding:3px 6px;"><span class="caret"></span></button>'
						+'<ul id="ul-position-'+value.id+'" class="dropdown-menu pull-right dropList" style="min-width:90px;margin-top:0px;">'
						+opt.li
						+'</ul>'
						+'</div>';
						 */

						s = '<div class="text-center relative ' + thisFpTime.replace(/:/g, "-") + ' ' + value.id + '-jump" id="cate-' + value.vid + '">'
							 + '<img class="fragment-img" id="img-' + value.id + '" src="' + value.fp + '"  ondblclick="view(\'' + value.id + '\');" onerror="nofind(\'' + value.fp +'\');"' + sty + ' />'
							 + '<div class="absolute ' + fpTime + '">' + thisFpTime + '</div><br/>'
							 + '<span class="pid">' + value.id + '</span>'
							//  +ly
							//   +bt
							//    +'<div class="desc">'+opt.desc+'</div>'
							//  +'<div class="absolute">'+opt.desc+'</div><br/>'

							 + '</div>';

						//////////////////////////////////////////////////////////////////////////////////


						if (smallPic) {
							if ((lb % linePicNum == 0)) {

								s += '<div class="clearfix breakWord">&nbsp;</div>';
							}
						}
						if (!smallPic) {
							if (lb % linePicNum == 0) {
								s += '<div class="clearfix breakWord">&nbsp;</div>';
							}
						}
						$('#makedImg').append(s);
						//出来第一张图的时候计算几张图片一行
						if (!isSetFpTime) {
							getLineWidth();
							isSetFpTime = true;
						}

						li = value.id + 1;
						lb++;
					});

					if (li) {
						$('#lastImg').html(li);
						$('#picNum').html(li);
					}
					if ($('#autoRunPic').prop('checked')) {
						sTop = $('#makedImg')[0].scrollHeight;
						$('#makedImg').scrollTop(sTop);
					}

				} else {
					noneDataNum = $('#noneData').data(); //请求无数据的次数
					if (noneDataNum.id > 5) {
						console.log('请求错误超过5次');
					} else {
						$('#noneData').data({
							'id' : noneDataNum.id++
						});
					}
				}

			},
			dataType : 'json',
			error : function () {
				$('#isOver').text('1');
				//alert('图片请求错误,再次尝试请求中!');
				live.tips("error",'图片请求错误,再次尝试请求中!');
			}
		});
	} else {
		//alert('null taskid');
	}
}

//播放功能
function view(viewTime) {
	//从刘志红那里取json列表
	$.get(listUrl, {
		'key' : taskid,
		'from_client' : true,
		'index' : viewTime,
		'type' : 0,
		'offset' : 100,
	}, function (data) {
		$('#allList').data(data);
		playAll(data);
	}, 'json');
	//传给王鹏
}

//播放1帧
function viewOne(viewTime) {
	//从刘志红那里取json列表
	$.get(listUrl, {
		'key' : taskid,
		'from_client' : true,
		'index' : viewTime,
		'type' : 0,
		'offset' : 1,
	}, function (data) {
		$('#allList').data(data);
		playOne(data);
	}, 'json');
	//传给王鹏
}
//提交删除
function del_submit() {
	d_sTime = $('input[name=d_sTime]').val();
	d_eTime = $('input[name=d_eTime]').val();
	d_title = $('input[name=d_videoName]').val();
	//////////////////////////////////////////////////////////
	d_type = $('input[name=d_imgType]').val();
	//////////////////////////////////////////////////////////

	$('#d_addInfo').attr('disabled', 'disabled');
	data = {
		'起始帧' : d_sTime,
		'结束帧' : d_eTime,
		'标题' : d_title
	};
	if (isNaN(d_sTime)) {
		//alert('起始帧有误,必须为数字类型');
		live.tips("error",'起始帧有误,必须为数字类型');
		return false;
	}
	if (isNaN(d_eTime)) {
		//alert('结束帧有误,必须为数字类型');
		live.tips("error",'结束帧有误,必须为数字类型');
		return false;
	}
	if (parseInt(d_sTime) > parseInt(d_eTime)) {
		//alert('起始帧不能大于结束帧');
		live.tips("error",'起始帧不能大于结束帧');
		return false;
	}
	if (!validAddInfo(data)) {
		return false;
	};
	dataSubmit = {
		'index' : index,
		'sTime' : d_sTime,
		'eTime' : d_eTime,
		'title' : d_title,
		'channel' : '',
		'album' : '',
		'pic' : ''
	}
	d_sty2Data.push(dataSubmit);
	addInfo(dataSubmit, 'del');
	$('input[name=d_sTime]').val('');
	$('input[name=d_eTime]').val('');
	index = index + 1;

	adTipRemove(); // 广告左右标识删除
	return true;
}

// 获取字符串长度
function getMixCharacterLength(str) {
	var singleCharachter,
	doubleCharacter,
	titleReg;

	singleCharachter = 0;
	doubleCharacter = 0;
	titleReg = new RegExp("[\\u4E00-\\u9FFF]");
	str = str.split("");

	for (var i in str) {
		if (titleReg.test(str[i])) {
			doubleCharacter += 2;

		} else {
			singleCharachter += 1;
		}
	}

	return doubleCharacter + singleCharachter;
}

//提交拆条
function dot_submit() {

	taskid = $('#taskid').html();
	if (!taskid.length) {
		//alert('任务ID为空,不能提交!');
		live.tips("error",'任务ID为空,不能提交!');
		return false;
	}
	
	var sTime = $('input[name=sTime]').val(),
	eTime = $('input[name=eTime]').val(),
	title = $('input[name=videoName]').val(),
	channel = $('input[name=categoryId]').val(),
	album = $('input[name=albumName]').val(),
	pic = $('input[name=imageId]').val() ? $('input[name=imageId]').val() : sTime,	
	data = {
		'起始帧' : sTime,
		'结束帧' : eTime,
		'标题' : title,
		'频道' : channel
	},
	dataSubmit = {
		'index' : index,
		'sTime' : sTime,
		'eTime' : eTime,
		'title' : title,
		'channel' : channel,
		'album' : album,
		'pic' : pic
	},
	toLego = true,

	priority = $('input[name=priority]:checked').val(), //优先级
	video_dpi = $('input[name=video_dpi]:checked').val(), //分辨率

	uid = $('#cp').children('option:selected').attr("uid"), //表示ugc用户id
	partnerId = $('#cp').children('option:selected').attr("partnerId"), //表示合作方id
	episodeType = $('#cp').children('option:selected').attr("episodeType"); //取值为0或1,1表示为ugc视频，0为普通ppc视频

	uid = !uid ? "" : uid;
	partnerId = !partnerId ? "" : partnerId;
	episodeType = !episodeType ? "" : episodeType;

	var albumId = '';
	if (album)
		albumId = $('input[name=albumId]').val();

	if (isNaN(sTime)) {
		//alert('起始帧有误,必须为数字类型');
		live.tips("error",'起始帧有误,必须为数字类型');
		return false;
	}
	if (isNaN(eTime)) {
		//alert('结束帧有误,必须为数字类型');
		live.tips("error",'结束帧有误,必须为数字类型');
		return false;
	}
	if (isNaN(pic)) {
		//alert('封面格式有误,必须为数字类型');
		live.tips("error",'封面格式有误,必须为数字类型');
		return false;
	}
	if (parseInt(sTime) > parseInt(eTime)) {
		//alert('起始帧不能大于结束帧');
		live.tips("error",'起始帧不能大于结束帧');
		return false;
	}
	if (parseInt(sTime) < 0) {
		//alert('起始帧不能为负数');
		live.tips("error",'起始帧不能为负数');
		return false;
	}
	numTime = $('#picNum').text();
	if (parseInt(eTime) >= parseInt(numTime)) {
		//alert('结束帧不存在,不能提交');
		live.tips("error",'结束帧不存在,不能提交');
		return false;
	}
	if (getMixCharacterLength(title) > 43) {
		//alert('标题长度不能超过43个字符（一个汉字等于两个字符）');
		live.tips("error",'标题长度不能超过43个字符（一个汉字等于两个字符）');
		return false;
	}

	$('#addInfo').attr('disabled', 'disabled');

	if (toLego) {	
		if (!validAddInfo(data)) {
			return false;
		};

		if(!accurateFrame.endSetted)
		{
			//alert("请在片尾使用精确化裁剪工具，快捷键Q");
			live.tips("error","请在片尾使用精确化裁剪工具，快捷键Q");
			return false;
		}			
		
		//提交数据到乐高
		p_vid = $('input[name=videoId]').val() ? $('input[name=videoId]').val() : 0;
		p_albumId = $('input[name=albumId]').val();
		videotype = $('input[name=videotype]:checked').val();
		if (videotype == -1) {
			p_vid = 0;
		}

		//去除删除部分
		splitData(sTime, eTime, true);
		//console.log(subData);
		if (!subData.length) {
			//alert('该条打了删除，不能再打拆条!');
			live.tips("error",'该条打了删除，不能再打拆条!');
			return false;
		}

		if ($('input[name=reTranscodeConfirm]').prop('checked')) {
			reTranscodeConfirm = 1;
		} else {
			reTranscodeConfirm = 0;
		}

		if ($('input[name=enableClound]').prop('checked')) {
			enableClound = 0;
		} else {
			enableClound = 1;
		}
		try {
			if (videonameArr.length) {
				var exist = false;
				for (var i in videonameArr) {
					if (videonameArr[i] == title) {
						exist = true;
					}
				}
				if (!exist) {
					//alert('提交失败，标题不存在!');
					live.tips("error",'提交失败，标题不存在!');
					return false;
				}
			}
		} catch (e) {}
		
///////////////////////////////   评分   ////////////////////////////////////		
		var rightIdentification = 0,
			options = {};
		
		delAdStr = "";
		
		$('#showInfo2').find('tr').each(function () {
			var s_id = parseInt($(this).children().eq(1).text()),
				e_id = parseInt($(this).children().eq(2).text());

			// 转换成VID
			var s = $('.'+s_id+'-jump').attr("id").split("-")[1],   
				e = $('.'+e_id+'-jump').attr("id").split("-")[1];

			
			if(delAdStr != "")
				delAdStr += ',';
			
			delAdStr +='0/'+s+'_0/'+e
			
			for(var dj in adLibList)
			{   
				if(adLibList[dj].s<=s && adLibList[dj].e>=s)
				{
					if(adLibList[dj].s==s && adLibList[dj].e == e)
					{
						rightIdentification++;
					}
					break;
				}
			}
		});		
		
		var adLibListLen = 1;
		if(adLibList.length!==0)
		{
			adLibListLen = adLibList.length;
		}
		
		options.from_client=true;  //绕过鉴权
		options.score = rightIdentification/adLibListLen*10; //  打分是在1~10分之前包括小数		
		options.func = "modify_ablum";
		
	
		
		$.ajax({
				cache : false,
				async : false,
				type : "post",
				url:live2vodModApi+"/v1/ablum/modify",
				data : {"channel_id":_channel_id,"ablum_id":p_albumId,"func":options.func,"score":options.score},
				success : function (res) {
					//console.log(res);
				},
				dataType : "json",
				error : function () {
					//alert('网络错误,请稍后再广告评分入库！');
					live.tips("error",'网络错误,请稍后再广告评分入库！');
				}
			});

//////////////////////////////////////////end  todo 还待优化 //////////////////////////////////////////////////////				
		
		videonameArr = [];
		$.ajax({
			cache : false,
			async : false,
			type : "post",
			url : 'http://lego.iqiyi.com/peditor/submit',
			timeout : 10000,
			data : {
				'data' : JSON.stringify({
					'videoId' : p_vid,
					'albumName' : album,
					'videoName' : title,
					'categoryId' : channel,
					'albumId' : p_albumId,
					'reTranscodeConfirm' : reTranscodeConfirm,
					'freeType' : freeType
				})
			},
			success : function (res) {
				if (res.code != 'A00000') {
					//alert(res.msg);
					live.tips("error",res.msg);
				} else {
					programId = res.data.programId;
					if (!programId) {
						//alert('乐高返回的programId为空!');
						live.tips("error",'乐高返回的programId为空!');
						return false;
					}
					
					var newPA = {
						title : title,
						cat : channel,
						alb : albumId,
						enableClound : enableClound,
						priority :priority,
						video_dpi : video_dpi,
						uid : uid,
						partnerId : partnerId,
						episodeType : episodeType
					}

					//提交数据给刘之红
					if (postData(subData, newPA, pic, programId, dataSubmit)) {
//////////////////////////制作数据统计///////////////////////////////////////////
var sSrc = $("#img-"+sTime).attr("src"),
	eSrc = $("#img-"+eTime).attr("src");

var s_fp_pos = sSrc.lastIndexOf('/') + 1,
	s_fp_time = sSrc.substr(fp_pos, 10),
	e_fp_pos = eSrc.lastIndexOf('/') + 1,
	e_fp_time = eSrc.substr(fp_pos, 10);

var seconds = (parseInt(e_fp_time) - parseInt(s_fp_time));

$.each(d_sty2Data, function(n, adData) {
	var adStartTime = adData.sTime, adEndTime = adData.eTime;
	if (sTime < adStartTime && eTime > adEndTime)
	{

		var	sSrc = $("#img-"+adStartTime).attr("src"),
			ads_fp_pos = sSrc.lastIndexOf('/') + 1,
			ads_fp_time = sSrc.substr(ads_fp_pos, 10),
			eSrc = $("#img-"+adEndTime).attr("src"),
			ade_fp_pos = eSrc.lastIndexOf('/') + 1,
			ade_fp_time = eSrc.substr(ade_fp_pos, 10);
		var ad_seconds = (parseInt(ade_fp_time) - parseInt(ads_fp_time));
		seconds = seconds - ad_seconds;
	}
});

VOD.Util.dl_click("http://epgapi.lego.iqiyi.com/st?bs=1&st=1&prid="+programId
								+"&pr_name="+encodeURIComponent(newPA.title)
								+"&pr_mins="+seconds
								+"&cname="+$('input[name=categoryName]').val()
								+"&u="+$('#userName').text()
								+"&cp="+_channel_name_str
								+"&bt="+new Date(parseInt(s_fp_time)*1000).format("yyyy-MM-dd hh:mm:ss")
								+"&et="+new Date(parseInt(e_fp_time)*1000).format("yyyy-MM-dd hh:mm:ss")
								+"&dst="+ new Date().format("yyyy-MM-dd hh:mm:ss")
								+"&ablum_name="+album
								+"&s_a_dot="+""                   //广告开始
								+"&s_m_dot="+sTime					//打点手动开始
								+"&e_a_dot="+""						//广告结束
								+"&e_m_dot="+eTime					//打点手动结束
								+"&ad_info="+delAdStr
);

//////////////////////////OCR统计///////////////////////////////////////////
if (!$("#ocr").hasClass("disabled")) {
	var ocrTitle = statisticOcrTitle;
	statisticOcrTitle="";
	VOD.Util.dl_click("http://epgapi.lego.iqiyi.com/st?bs=1&st=3&programId="+programId
						+"&programName="+encodeURIComponent(newPA.title)
						+"&channelId="+_channel_id
						+"&channelName="+_channel_name_str
						+"&categoryName="+$('input[name=categoryName]').val()
						+"&ocrTitle="+encodeURIComponent(ocrTitle)
						+"&userTitle="+encodeURIComponent(newPA.title)
						+"&user="+$('#userName').text()
						);
}
//////////////////////////长视频智能分析统计///////////////////////////////////////////
// sty2Data 缓存sty2数据
// d_sty2Data 缓存提交后的广告头和尾

var headerCompleteNumbers=headerIncompleteNumbers=headerFaultNumbers=0,
	lastCompleteNumbers=lastIncompleteNumbers=lastFaultNumbers=0,
	adCompleteNumbers=adIncompleteNumbers=adFaultNumbers=0;

// 计算广告智能分析正确数
var eq_sTime,eq_eTime,
	headerSty2Index,headerSty2Length,headerListIndex,
	lastSty2Index,lastSty2Length,lastListIndex,
	gtSty2Flag,ltSty2Flag;
var sty2DataList = sty2Data.list;
if (channelInfo.length==0 || channelInfo[0].sty2 == 1)
{
$.each(d_sty2Data, function(n, adData) {
	var sVid = $('.'+adData.sTime+'-jump').attr("id").split("-")[1],  
		eVid = $('.'+adData.eTime+'-jump').attr("id").split("-")[1];
	$.each(sty2DataList,function (i,item){
		$.each(item.video_list, function(j, sty2Id){
			if (item.type == VOD.CONFIG("adLib"))
			{
				var length = item.video_list.length;
				if (sVid == sty2Id)
				{
					headerSty2Index=i;
					headerListIndex=j;
					headerSty2Length=length;
					eq_sTime=sty2Id;
				} else if (eVid == sty2Id)
				{
					lastSty2Index=i;
					lastListIndex=j;
					lastSty2Length=length;
					eq_eTime=sty2Id;
				}
				if (j==0 && sVid < sty2Id)
				{
					ltSty2Flag = true;
				}
				if (j==length-1 && eVid > sty2Id)
				{
					gtSty2Flag = true;
				}
			}
		});
	});


	if (eq_sTime==null && eq_eTime==null)
	{
		if (ltSty2Flag && gtSty2Flag)
		{
			adIncompleteNumbers++;
		} else 
		{
			adFaultNumbers++;
		}
		
	} else if (eq_sTime==null || eq_eTime==null)
	{
		adIncompleteNumbers++;
	} else if (eq_sTime!=null && eq_eTime!=null)
	{
		var adRound = eq_eTime - eq_sTime + 1;
		if(headerSty2Index == lastSty2Index && adRound == headerSty2Length)
		{
			adCompleteNumbers++;
		} else if (headerSty2Index == lastSty2Index && adRound != headerSty2Length)
		{

			adIncompleteNumbers++;
		} else if (headerSty2Index != lastSty2Index)
		{
			if (headerListIndex != 0 || lastListIndex != lastSty2Length - 1)
			{
				adIncompleteNumbers++;
			} else {
				var index = headerSty2Index;
				var flag = true;
				while(flag) {
					if (index == lastSty2Index)
					{
						adCompleteNumbers++;
						flag = false;
					} else {
						var videoList = sty2DataList[index].video_list;
						var nextVideoList = sty2DataList[index + 1].video_list;
						if ((nextVideoList[0] - videoList[videoList.lenth - 1]) >= 2 )
						{
							adIncompleteNumbers++;
							flag = false;
						}
					}
					index++;
				}
			}
		}
	}
	
});
// 广告智能分析提交数请空
d_sty2Data=[];
headerSty2Index=null;
eq_sTime=null;
eq_eTime=null;

sVid = $('.'+sTime+'-jump').attr("id").split("-")[1];
eVid = $('.'+eTime+'-jump').attr("id").split("-")[1];
// 计算片头和片尾正确数
$.each(sty2DataList,function (i,item){
	$.each(item.video_list, function(j, sty2Id){
		if (item.type == VOD.CONFIG("adLibHead"))
		{
			if (sVid == sty2Id)
			{
				headerSty2Index = j;
				eq_sTime=sty2Id;
			}
		}
		if (item.type == VOD.CONFIG("adLibTail"))
		{
			if (eVid == sty2Id)
			{
				lastSty2Index = j;
				lastSty2Length = item.video_list.length;
				eq_eTime=sty2Id;
			}
		}
	});
});

if (eq_sTime == null)
{
	headerFaultNumbers++;
} else if(eq_sTime != null && headerSty2Index==0)
{
	headerCompleteNumbers++;
} else 
{
	headerIncompleteNumbers++;
}

if (eq_eTime == null)
{
	lastFaultNumbers++;
} else if(eq_eTime != null && lastSty2Index==lastSty2Length-1)
{
	lastCompleteNumbers++;
} else 
{
	lastIncompleteNumbers++;
}

VOD.Util.dl_click("http://epgapi.lego.iqiyi.com/st?bs=1&st=2&channelId="+_channel_id
						+"&channelName="+_channel_name_str
						+"&channelCode="+channel_name
						+"&programId="+programId
						+"&programName="+encodeURIComponent(newPA.title)
						+"&categoryName="+$('input[name=categoryName]').val()
						+"&albumName="+album
						+"&programTime="+seconds
						+"&headerCompleteNumbers="+headerCompleteNumbers
						+"&headerIncompleteNumbers="+headerIncompleteNumbers
						+"&headerFaultNumbers="+headerFaultNumbers
						+"&lastCompleteNumbers="+lastCompleteNumbers
						+"&lastIncompleteNumbers="+lastIncompleteNumbers
						+"&lastFaultNumbers="+lastFaultNumbers
						+"&adCompleteNumbers="+adCompleteNumbers
						+"&adIncompleteNumbers="+adIncompleteNumbers
						+"&adFaultNumbers="+adFaultNumbers
						+"&user="+$('#userName').text()
						);
}
/////////////////////////////end//////////////////////////////////////////////////////							
						
						//alert('打点成功');
						live.tips("success",'打点成功');
						fgTipRemove();						
						return true;
					}
				}
			},
			dataType : "json",
			error : function (XMLHttpRequest, status) {
				//alert('网络错误,请稍后再提交！');
				if(status=='timeout'){
					ajaxTimeoutTest.abort();
　　　　　			live.tips("error",'接口/peditor/submit调用超时10秒未响应！请联系乐高相关负责人员！');
　　　　		} else {
					live.tips("error",'网络错误,请稍后再提交！');
				}
				$('#addInfo').removeAttr('disabled').html('提交');
			}
		});
	}
}

$(document).ready(function () {

	var sty = '';

	$('#submitStartTime').click(function () {

		if (VOD.DAO.storageData('ASS') == 'on') {
			if (!VOD.DAO.storageData('sty-intval')) {
				sty = setInterval(VOD.DAO.getSty, 10000);
				VOD.DAO.storageData('sty-intval', 1);
			}
		} else {
			clearInterval(sty);
			VOD.DAO.storageData('sty-intval', 0);
			VOD.DAO.storageData('sty-index', 0);
			VOD.g_mi = 0;
			VOD.g_i = 0;
		}

		// 清除已列拆条
		$('.inner-table').parents('tr').remove();
		$('.merg-seg-tips,.auto-seg-tips').show();

		if (error.length) {
			//alert(error);
			live.tips("error",error);
			return false;
		}

		index = 1;
		stime = 0;
		etime = 0;
		pic = 0;
		taskid = 0;
		lastImg = 0;
		delList = [];
		subData = [];
		needDatas = [];
		isStart = isSetFpTime = false;
		lb = 1;
		firstFpTime = 0;
		
		last_i = 0;   // 最后一次精确化显示索引
		isOver = 0;   // 停止自动拉取图片
		adLibList = [];

		$('#showInfo2,#showInfo1').empty();
		if (!$('#changeBigPic').hasClass('btn-primary')) {
			fpTime = 'fp_time';
		} else {
			fpTime = 'fp_time2';
		}
		start = validStart();
		if (!start) {
			return false;
		}
		$('#makedImg').html('正在请求数据，请等待！');
		
		code = channel_name;
		$this = $(this);

		$.ajax({
			type : "get",
			url : initUrl,
			data : {
				'start' : start,
				'period' : period,
				'code' : code,
				'from_client' : true
			},
			success : function (data) {
				if (data.taskid) {
					$('#taskid').html(data.taskid);
					$('#lastImg').html(0);
					//开始请求数据
					isStart = true;
					$('#makedImg').empty();
					getData();
				} else {
					//alert('系统错误:任务id为空');
					live.tips("error",'系统错误:任务id为空');
					return false;
				}
			},
			dataType : "json",
			error : function () {
				//alert('网络错误');
				live.tips("error",'网络错误');
			}
		});
		//////////////////////////////////////////
		FFSq = [];
		add = [];
		del = [];
		//////////////////////////////////////////

	})
	$('#changeBigPic').click(function () {
		lb = 1;
		$('.right img').css({
			'width' : '280px',
			'height' : '210px'
		});
		$('#picWH').html('style="width:280px;height:210px"');
		$(this).addClass('btn-primary');
		$('#changeSmallPic').removeClass('btn-primary');
		$('.breakWord').remove();
		if (isClicked) {
			sTop = $('#makedImg').scrollTop() + $('.red').offset().top;
			$('#makedImg').scrollTop(sTop);

		}
		smallPic = false;
		$('.fp_time').removeClass('fp_time').addClass('fp_time2');

		$('.in-out-mark-s').addClass('in-out-mark-b');

		fpTime = 'fp_time2';
		getLineWidth();
		addClearFix();

		$("#play-one").css({
			width : "274px",
			height : "210px"
		});
	})
	$('#changeSmallPic').click(function () {
		lb = 1;
		$('.right img').css({
			'width' : '120px',
			'height' : '80px'
		});
		$('#picWH').html('style="width:120px;height:80px"');
		$(this).addClass('btn-primary');
		$('#changeBigPic').removeClass('btn-primary');
		$('.breakWord').remove();
		if (isClicked) {
			sTop = $('#makedImg').scrollTop() + $('.red').offset().top;
			$('#makedImg').scrollTop(sTop);
		}
		smallPic = true;
		$('.fp_time2').removeClass('fp_time2').addClass('fp_time');
		$('.in-out-mark-s').removeClass('in-out-mark-b');
		fpTime = 'fp_time';
		getLineWidth();
		addClearFix();
		$("#play-one").css({
			width : "140px",
			height : "105px"
		});
	})

	// 标题、专辑、合作方suggest鼠标移出隐藏
	$('.cn_hide,.cn_hide2,.cn_hide3').hover(function () {}, function () {
		$(this).hide();
	})

	$('#reviewInfo').click(function () {
		var sTime = $('input[name=sTime]').val(),
		eTime = $('input[name=eTime]').val();

		data = {
			'起始帧' : sTime,
			'结束帧' : eTime
		};
		if (!validAddInfo(data)) {
			return false;
		};
		if (parseInt(sTime) > parseInt(eTime)) {
			//alert('起始帧不能大于结束帧');
			live.tips("error",'起始帧不能大于结束帧');
			return false;
		}
		numTime = $('#picNum').text();
		if (parseInt(eTime) >= parseInt(numTime)) {
			//alert('结束帧不存在,不能预览');
			live.tips("error",'结束帧不存在,不能预览');
			return false;
		}
		splitData(sTime, eTime, true); //去除删除部分
		review();
	})
	$('#d_reviewInfo').click(function () {
		var dsTime = $('input[name=d_sTime]').val(),
		deTime = $('input[name=d_eTime]').val();

		data = {
			'起始帧' : dsTime,
			'结束帧' : deTime
		};
		if (!validAddInfo(data)) {
			return false;
		};
		if (parseInt(dsTime) > parseInt(deTime)) {
			//alert('起始帧不能大于结束帧');
			live.tips("error",'起始帧不能大于结束帧');
			return false;
		}
		numTime = $('#picNum').text();
		if (parseInt(deTime) >= parseInt(numTime)) {
			//alert('结束帧不存在,不能预览');
			live.tips("error",'结束帧不存在,不能预览');
			return false;
		}
		splitData(dsTime, deTime, false); //去除删除部分
		review();
	})
	$('#d_addInfo').click(function () {
		if (del_submit()) {
			//alert('删除成功');
			live.tips("success",'删除成功');
		}
		$('#d_addInfo').removeAttr('disabled').html('提交');
	})
	$('#addInfo').click(function () {
		if (dot_submit()) {
			//alert('打点成功');
			live.tips("success",'打点成功');
		}
		$('#addInfo').removeAttr('disabled').html('提交');
	});
	$('#jumpSubmit').click(function () {
		jumpType = $('select[name=jumpType]').val();
		if (jumpType == 1) {
			var jc = $('#jumpContent').val();
			if (!isJumpData(jc, 1)) {
				//alert('跳转输入格式错误');
				live.tips("error",'跳转输入格式错误');
				return false;
			}
			jumpContent = jc.replace(/:/g, "-");
			if (!$('.relative').hasClass(jumpContent)) {
				temStr = jumpContent.substr(jumpContent.length - 2);
				if (temStr.length == 2 && temStr.substr(0, 1) == '0') {
					temStr = temStr.charAt(temStr.length - 1);
				}
				lasStr = parseInt(temStr);
				if (lasStr == 0) {
					lasStr += 10;
				}
				beforeStr = jumpContent.substr(0, jumpContent.length - 2)
					untilStr = lasStr - 10;
				if (untilStr < 0)
					untilStr = 0;

				for (var i = lasStr; i >= untilStr; i--) {

					if (i < 10) {
						us = 0 + String(i);
					} else {
						us = String(i);
					}
					us = beforeStr + us;

					if ($('.relative').hasClass(us)) {
						jumpContent = us;
						break;
					}
				}
			}
			if ($('.relative').hasClass(jumpContent)) {
				$('#makedImg').scrollTop(0);
				sTop = $('.' + jumpContent).offset().top - 100;
				$('#makedImg').scrollTop(sTop);
			} else {
				//alert('没有这个时间点');
				live.tips("error",'没有这个时间点');
			}
		} else {
			var jc = $('#jumpContent').val();
			if (!isJumpData(jc, 0)) {
				//alert('跳转输入格式错误');
				live.tips("error",'跳转输入格式错误');
				return false;
			}
			jumpContent = jc + '-jump';
			if ($('.relative').hasClass(jumpContent)) {
				$('#makedImg').scrollTop(0)
				sTop = $('.' + jumpContent).offset().top - 100;
				$('#makedImg').scrollTop(sTop);
			} else {
				//alert('没有这帧');
				live.tips("error",'没有这帧');
			}
		}
	})
	$('#makedImg').on('click', 'img,.transparent_class', function () {
		isClicked = true;  // 大小图片切换滚动到当前图片用
		
		if($(this).parent().find(".layout").hasClass("red"))
			return ;
		
		$('.layout').removeClass('red');
		
		if($(this).parent().find(".layout").length !== 0)
			$(this).parent().find(".layout").addClass("red");
		else		
		$(this).parent().append('<div class="layout transparent red" onClick="this.remove();">&nbsp;</div>');
		pic = etime = stime = $(this).parent().find('.pid').text().replace(/\s+/g, "");
	})
	$('#adv').click(function () {
		$('input[name=videoName]').val('广告');
		$('input[name=categoryName],input[name=albumName],input[name=imageId]').attr('disabled', 'disabled');
	});
	$('#mer').click(function () {
		$('input[name=videoName]').val('');
		$('input[name=categoryName],input[name=albumName],input[name=imageId]').removeAttr('disabled');
	});
	$('.cVideo').click(function () {
		$('input[name=albumName],input[name=imageId],input[name=categoryName]').removeAttr('disabled');
	})
	$('select[name=jumpType]').change(function () {
		if ($(this).val() == 1) {
			$('#jumpContent').val('00:00:00');
		} else {
			$('#jumpContent').val('0');
		}
	})
	$('#autoRunPic').click(function () {
		if ($(this).prop('checked')) {
			sTop = $('#makedImg')[0].scrollHeight;
			$('#makedImg').scrollTop(sTop);
		}
	})

	$("input[name=videotype]").bind('click', function () {

		videonameArr = [];
		$("input[name=videoName]").val("");
		$("input[name=videoId]").val("");
		$("input[name=albumId]").val("");
		$("input[name=albumName]").val("");
		if ($(this).val() == -1) {
			$("#ocr").show();
			$("#acr").show();

		} else {
			$("#ocr").hide();
			$("#acr").hide();
		}

		var categoryName = $("input[name=categoryName]").val();
		VOD.Util.setCooperativePartner(categoryName);
	});

	$("input[name=videoName]").focus(function(){$(this).addClass("videoName")}).blur(function(){$(this).removeClass("videoName");});
	//奇艺频道suggest标题接口
	$("input[name=videoName]").bind('input propertychange', function () {
		var word = $(this).val();
		if (getMixCharacterLength(word) > 43) {
			$(this).css("border-color", "red");
			$("#limit").show();
		} else {
			$(this).attr("style", "");
			$("#limit").hide();
		}

		if (error.length) {
			$("input[name=videoId]").val("");
			return false;
		}

		if (!word) {
			$("input[name=videoId]").val("");
			$('.cn_hide').hide();
		}
		var videotype = $('input[name=videotype]:checked').val();
		if (word && videotype != -1) {
			$.get('http://lego.iqiyi.com/suggest/simple-video', {
				'word' : word,
				'type' : 'properTitle',
				'isMade' : videotype
			}, function (item) {
				$('.cn_hide').empty();
				if (item.code == 'A00000') {
					var messages = item.data;
					if (messages.length) {
						videonameArr = [];
						$.each(messages, function (index, message) {
							videonameArr.push(message.properTitle);
							var rhtml = '<p class="spe" onclick="put_input(\'' + message.entityId + '\',\'' + message.properTitle + '\',\'' + message.categoryId + '\',\'' + message.categoryName + '\',\'' + message.albumId + '\',\'' + message.albumDisplayName + '\')" style="margin:0px;padding-bottom:5px;cursor:pointer">' + message.properTitle + '</p>';
							$('.cn_hide').append(rhtml);
						})
						$('.cn_hide').show();
					} else {
						$("input[name=videoId]").val("");
						$('.cn_hide').hide();
					}
				}
			}, 'json')
		}

	});

	$('input[name=eTime]').blur(function () {
		c_sTime = $(this).val();
		s_sTime = $('input[name=sTime]').val();

		if (s_sTime == '' && isNaN(s_sTime))
			return;

		if (c_sTime != '' && !isNaN(c_sTime)) {
			if ($('input[name=videotype]:checked').val() == -1) {
				taskid = $('#taskid').html();
				show = taskid + '-' + channel_name + '-' + today + '-' + s_sTime + '-' + c_sTime;
				$('input[name=videoName]').val(show);

				var ocrFirstTitle = binSearchOcrTitle(s_sTime, c_sTime).shift();
				if (ocrFirstTitle) {
					$("input[name=videoName]").val(ocrFirstTitle);
					$("input[name=videoName]").attr("eut", encodeURIComponent(ocrFirstTitle));
				}

			}
		}
	})
	setInterval(getData, 5000);   // 获取图片数据
	//setInterval(getCate,20000);
	setInterval(getSty2,19000);   // 智能识别数据
	setInterval(getOcr, 23000);
	setInterval(getAcr, 11000);
});

function put_input(videoId, vName, cateId,categoryName, albumId, albumName) {
	$('input[name=videoId]').val(videoId);
	$("input[name=videoName]").val(vName);
	$("input[name=categoryName]").val(categoryName);
	$("input[name=categoryId]").val(cateId);
	if (albumId != 0)
		$("input[name=albumId]").val(albumId);
	else
		$("input[name=albumId]").val("");

	if (albumName != 'undefined')
		$("input[name=albumName]").val(albumName);
	else
		$("input[name=albumName]").val("");

	$('input[name=albumName],input[name=imageId],input[name=categoryName]').attr('disabled', 'disabled');

	$('.cn_hide').hide();
}

window.onbeforeunload = validUnload;
function validUnload() {
	var warning = "确认要重新打点吗？";
	return warning;
}

function keyEvent(e) {
	/*
	// 自动拆条相关
	if (!$('[action-name="segmentation-params-tab"]').parent('li').hasClass('active'))
		return;
	*/
	
	// textarea去除快捷键
	if ($('textarea[name=desc]').is(":focus")) {
		return;
	}	

	// 文本框去除快捷键
	if ($("#cForm,#dForm").find('input[type=text]').is(":focus")) {
		return;
	}
	
	if (e.keyCode == 82) // ocr快捷键 R
	{
		if(!isVideoType1())
		{
			if($("#ocr").hasClass("disabled"))
			{
				live.tips("error",'当前ocr不可用！');
			}
			else
			{
				$("#ocr").trigger("click");
			}
		}
		return;
	}

	if (e.keyCode == 88) // ocr快捷键 x
	{
		VOD.Evt.ShowAndHideSegmentationList();
		return;
	}
	
	if (e.keyCode == 87) // 鼠标悬浮快捷键w
	{
		if (playOneInfo.mouseenter == true) {
			playOnePosition.left = playOneInfo.left;
			playOnePosition.top = playOneInfo.top;

			viewOne(playOneInfo.time);
		}
		return;
	}

	if (e.which == 48 && e.ctrlKey) {
		$('[role="alert"]').hide();
		return;
	}

	if (e.which == 90) { //提交删除
		if (del_submit()) {
			//alert('删除成功');
			live.tips("success","删除成功");
		}
		return;
	}
	
	if (e.which == 65) { //提交打点
		if (dot_submit()) {
			//alert('打点成功');
			live.tips("success","打点成功");
		}
		$('#addInfo').removeAttr('disabled').html('提交');
		return;
	}

	if (e.which == 86) { //删除开始
		if (stime) {
			var red = $('.red').parent().find("div");

			if (red.hasClass('ad-l') || red.hasClass('fragment-r') || red.hasClass('fragment-l')) {
				return false;
			}
			
			$('.ad-l').remove();
			if (!$('.old').hasClass('ad-l') && !$('.old').hasClass('ad-r') && $('.old').hasClass('fragment-r') && $('.old').hasClass('fragment-l')) {
				$('.old').remove();
			}
			$('.red').addClass('ad-l');
			$('.ad-l').removeClass('ad-r');
			$('.ad-l').html("广<br />告<br />头");
			$('input[name=d_sTime]').val(stime);
		}
		return;
	}
	if (e.which == 67) { //删除结束
		if (etime) {
			var red = $('.red').parent().find("div");

			if (red.hasClass('ad-r') || red.hasClass('fragment-r') || red.hasClass('fragment-l')) {
				return false;
			}
			tmp_stime = $('input[name=d_sTime]').val();
			if (tmp_stime.length && parseInt(tmp_stime) > parseInt(etime)) {
				//alert('起始帧不能大于结束帧!');
				live.tips("error","起始帧不能大于结束帧");
				return false;
			}
			$('.ad-r').remove();
			if (!$('.old').hasClass('ad-r') && !$('.old').hasClass('ad-l') && $('.old').hasClass('fragment-r') && $('.old').hasClass('fragment-l')) {
				$('.old').remove();
			}
			$('.red').addClass('ad-r');
			$('.ad-r').removeClass('ad-l');
			$('.ad-r').html("广<br />告<br />尾");
			$('input[name=d_eTime]').val(etime);
		}
		return;
	}

	if (e.which == 81) { // 打点精确化,调出该图片所有上所对应的所有帧  对应快捷键为 q
		if ($('.red').hasClass('fragment-l'))
			accurateStartEndPlay($('.fragment-l').parent().find("img").attr("src"));
		else if($('.red').hasClass('fragment-r'))
			accurateStartEndPlay($('.fragment-r').parent().find("img").attr("src"));
		else if($('.red').hasClass('ad-l'))
			accurateStartEndPlay($('.ad-l').parent().find("img").attr("src"));
		else if($('.red').hasClass('ad-r'))
			accurateStartEndPlay($('.ad-r').parent().find("img").attr("src"));		
		return;
	}

	if (e.which == 27) { // 打点精确化,调出该图片所有上所对应的所有帧  对应快捷键为 ESC
		accurateStartEndRemove();
		return false;
	}

	if (e.which == 70) { //打开始
		if (stime) {
			var red = $('.red').parent().find("div");

			if (red.hasClass('ad-l') || red.hasClass('ad-r') || red.hasClass('fragment-l')) {
				return false;
			}
			$('.fragment-l').remove();
			if (!$('.old').hasClass('fragment-l') && !$('.old').hasClass('fragment-r') && $('.old').hasClass('ad-r') && $('.old').hasClass('ad-l')) {
				$('.old').remove();
			}
			
			$('.red').removeClass('fragment-r');
			$('.red').addClass('fragment-l');
			$('.fragment-l').html("片<br />头");
			$('input[name=sTime]').val(stime);
			
			accurateFrame.head = '';
			accurateFrame.headSetted = false;				
		}
		return;
	}
	if (e.which == 68) { //打结束
		if (etime) {
			var red = $('.red').parent().find("div");
			if (red.hasClass('ad-l') || red.hasClass('ad-r') || red.hasClass('fragment-r')) {
				return false;
			}
			tmp_stime = $('input[name=sTime]').val();
			if (tmp_stime.length && parseInt(tmp_stime) > parseInt(etime)) {
				//alert('起始帧不能大于结束帧!');
				live.tips("error","起始帧不能大于结束帧");
				return false;
			}
			$('.fragment-r').remove();
			if (!$('.old').hasClass('fragment-r') && !$('.old').hasClass('fragment-l') && !$('.old').hasClass('ad-l') && !$('.old').hasClass('ad-r')) {
				$('.old').remove();
			}
			
			$('.red').removeClass('fragment-l');
			$('.red').addClass('fragment-r');
			$('.fragment-r').html("片<br />尾");
			$('input[name=eTime]').val(etime);
			s_sTime = $('input[name=sTime]').val();
			if ($('input[name=videotype]:checked').val() == -1) {
				taskid = $('#taskid').html();
				show = taskid + '-' + channel_name + '-' + today + '-' + s_sTime + '-' + etime;
				$('input[name=videoName]').val(show);
				var ocrFirstTitle = binSearchOcrTitle(tmp_stime, etime).shift();
				if (ocrFirstTitle) {
					$("input[name=videoName]").val(ocrFirstTitle);
					$("input[name=videoName]").attr("eut", encodeURIComponent(ocrFirstTitle));
				}
			}
			accurateFrame.end = '';
			accurateFrame.endSetted = false;
		}
		return;
	}
	if (e.which == 83) { //打图片
		if (pic) {
			if ($('.layout').hasClass('red block') || $('.layout').hasClass('blue block') || $('.layout').hasClass('red blue yellow block')) {
				return false;
			}
			$('.block').remove();
			$('.red').addClass('block');
			$('input[name=imageId]').val(pic);
		}
		return;
	}

	if (e.keyCode == 37) { //左
		var prev = $('.red').parent().prev();
		if (prev.length) {
			if ($(prev).hasClass('breakWord')) {
				prev = $(prev).prev();
			}
			$('.layout').removeClass('red').addClass('old');
			
			if($(prev).find(".layout").length !== 0)
				$(prev).find(".layout").addClass("red");
			else
				$(prev).append('<div class="layout transparent red" onClick="this.remove();">&nbsp;</div>');
			
			pic = etime = stime = $(prev).find('.pid').text().replace(/\s+/g, "");
		}
		return false;
	}
	if (e.keyCode == 39) { //右
		var next = $('.red').parent().next();
		if (next.length) {
			if ($(next).hasClass('breakWord')) {
				next = $(next).next();
			}
			$('.layout').removeClass('red');
			
			if($(next).find(".layout").length !== 0)
				$(next).find(".layout").addClass("red");
			else			
			$(next).append('<div class="layout transparent red" onClick="this.remove();">&nbsp;</div>');
			pic = etime = stime = $(next).find('.pid').text().replace(/\s+/g, "");
		}
		return false;
	}
	if (e.keyCode == 38) { //上
		if (smallPic) {
			var top = $('.red').parent().prevAll(":eq(" + linePicNum + ")");
		} else {
			var top = $('.red').parent().prevAll(":eq(" + linePicNum + ")");
		}

		if (top.length) {
			$('.layout').removeClass('red').addClass('old');
			
			if($(top).find(".layout").length !== 0)
				$(top).find(".layout").addClass("red");
			else			
			$(top).append('<div class="layout transparent red" onClick="this.remove();">&nbsp;</div>');
			pic = etime = stime = $(top).find('.pid').text().replace(/\s+/g, "");
		}
		return false;
	}
	if (e.keyCode == 40) { //下
		if (smallPic) {
			var bot = $('.red').parent().nextAll(":eq(" + linePicNum + ")");
		} else {
			var bot = $('.red').parent().nextAll(":eq(" + linePicNum + ")");
		}
		if (bot.length) {
			$('.layout').removeClass('red').addClass('old');
			
			if($(bot).find(".layout").length !== 0)
				$(bot).find(".layout").addClass("red");
			else			
			$(bot).append('<div class="layout transparent red" onClick="this.remove();">&nbsp;</div>');
			pic = etime = stime = $(bot).find('.pid').text().replace(/\s+/g, "");
		}
		return false;
	}
}


//$('#click').trigger('click');
//shuffleAll()乱序播放
//shuffleReplicationAll()乱序重复片段播放


// 广告 头部标识部分


/////////////////////identification ////////////////////////////////////////

$("#ocr").click(function () {
	$("#myModalLabel").text("修改标题");
	$("#myModalLabel").attr("modal-type", "ocr");
	$(".modal-footer").show();
	setOcrTitleList();
});

$("#acr").click(function () {
	$("#myModalLabel").text("修改描述");
	$("#myModalLabel").attr("modal-type", "acr");
	$(".modal-footer").show();
	setAcrTitleList();
});

$(".identification").bind('click', function () {

	if ($("#myModalLabel").text() == "定时提醒")
		VOD.Evt.RegularTimeRemind();
	else {
		if (isVideoType1() == 1)
			return;

		var type = $("#myModalLabel").attr("modal-type");
		if (type == 'ocr')
			setVideoName();
		else if (type == 'acr')
			setVideoDesc();
	}

});

function dbSetName() {

	$(".identification").trigger('click');

}

//  the ocr title of list to pop window
function setOcrTitleList() {
	var s_sTime = $('input[name=sTime]').val();
	var s_eTime = $('input[name=eTime]').val();

	if (s_sTime == "undefined" || s_sTime == "" || s_eTime == "undefined" || s_eTime == "") {
		$("#radio-title-list").html("<div style=\"color:grey;height:150px;\">起始结束帧不能为空！</div>");
		return;
	}

	var tmp = binSearchOcrTitle(s_sTime, s_eTime);

	if (tmp == '') {
		$("#radio-title-list").html("<div style=\"color:grey;height:150px;\">没有识别到的标题！</div>");
		return;
	}

	var checkboxHtml = '';
	var k = 1;

	var outTmp = $("input[name=videoName]").attr("eut");
	var eut = '';
	for (var i in tmp) {

		if (outTmp != '') {
			eut = encodeURIComponent(tmp[i]);
			if (outTmp == eut) {
				ck = 'checked';
			} else {
				ck = '';
			}
		} else {
			if (k == 1)
				ck = 'checked';
			else
				ck = '';
			k++;
		}

		checkboxHtml += '<div class="radio">'
		 + '<label  ondblclick="dbSetName()">'
		 + '<input type="radio" name="optionsRadios" value="' + eut + '" ' + ck + '>'
		 + tmp[i]
		 + '</label>'
		 + '</div>';
	}

	$("#radio-title-list").html(checkboxHtml);
}


// set program name
function setVideoName() {
	var val = $('input:radio[name="optionsRadios"]:checked').parent().text();
	statisticOcrTitle = val;
	$("input[name=videoName]").val(val);
	$("input[name=videoName]").attr("eut", $('input:radio[name="optionsRadios"]:checked').val());
}

// 判断是否是覆盖已制作成片的节目
function isVideoType1() {
	if ($('input[name=videotype]:checked').val() == -1)
		return 0;
	else
		return 1;
}

function binSearchOcrTitle(start, end) {
	var titleList = [];
	var tmp = [];
	var len = g_ocrList.length;

	if (len) {
		for (var i in g_ocrList) {
			if (start >= g_ocrList[i]['first'] && start <= g_ocrList[i]['last'] || g_ocrList[i]['first'] >= start && g_ocrList[i]['last'] <= end || end >= g_ocrList[i]['first'] && end <= g_ocrList[i]['last']) {
				tmp[g_ocrList[i]['title']] = i; // 去重复
			}
		}

		for (var j in tmp) {
			titleList.push(j);
		}

	}
	return titleList;
}

var g_mutex = 0; // 防止数据不一致
var g_ocrList = []; // ocr 识别出的title数据
function getOcr() {
	g_mutex = 1;
	var tmp = [];
	if (taskid && isStart) {
		$.get(ocrUrl, {
			'key' : taskid,
			'index' : 0,
			'type' : 1,
			'from_client' : true
		}, function (data) {

			ocr_list = data.list;
			var len = ocr_list.length;
			g_ocrIndex = len;
			if (len) {
				for (var i in ocr_list) {
					if (ocr_list[i]['text'] == '' || ocr_list[i]['text'].length == 1 || ocr_list[i]['video_list'] == '')
						continue;

					for (var j in ocr_list[i]['video_list']) {
						ocr_list[i]['video_list'][j] = ocr_list[i]['video_list'][j] - 1;
					}

					var tmp2 = [];

					if (ocr_list[i]['video_list'].length == 1) {
						tmp2['first'] = tmp2['last'] = ocr_list[i]['video_list'].shift();
					} else {
						tmp2['first'] = ocr_list[i]['video_list'].shift();
						tmp2['last'] = ocr_list[i]['video_list'].pop();

					}
					tmp2['title'] = ocr_list[i]['text'];
					tmp.push(tmp2);
				}
			}

			if (tmp != '') {
				if ($("#ocr").hasClass("disabled")) {
					$("#ocr").removeClass("disabled");
				}

				g_ocrList = tmp;
			}
			g_mutex = 0;
		}, 'json')
	}
}
// has marked ad will be removed
function adTipRemove() {
	$('.ad-l').remove();
	$('.ad-r').remove();
}

// has marked fragment will be removed
function fgTipRemove() {
	$('.fragment-l').remove();
	$('.fragment-r').remove();
}

/////////////////////acr///////////////////

//  the ocr title of list to pop window
function setAcrTitleList() {
	var s_sTime = $('input[name=sTime]').val();
	var s_eTime = $('input[name=eTime]').val();

	if (s_sTime == "undefined" || s_sTime == "" || s_eTime == "undefined" || s_eTime == "") {
		$("#radio-title-list").html("<div style=\"color:grey;height:150px;\">起始结束帧不能为空！</div>");
		return;
	}

	var tmp = binSearchAcrTitle(s_sTime, s_eTime);

	if (tmp == '') {
		$("#radio-title-list").html("<div style=\"color:grey;height:150px;\">没有识别到描述！</div>");
		return;
	}

	var checkboxHtml = '';
	var k = 1;

	var outTmp = $("textarea[name=desc]").attr("eut");

	for (var i in tmp) {

		eut = encodeURIComponent(tmp[i]);
		if (outTmp != '') {
			var f = new RegExp(eut, 'gi');
			if (f.test(outTmp)) {
				ck = 'checked';
			} else {
				ck = '';
			}
		} else {
			if (k == 1)
				ck = 'checked';
			else
				ck = '';
			k++;
		}

		checkboxHtml += '<div class="checkbox">'
		 + '<label  ondblclick="dbSetName()">'
		 + '<input type="checkbox" name="optionsCheckboxs" value="' + eut + '" ' + ck + '>'
		 + tmp[i]
		 + '</label>'
		 + '</div>';
	}

	$("#radio-title-list").html(checkboxHtml);
}

function setVideoDesc() {
	var val = '';
	var var2 = '';
	var val1 = $('input:checkbox[name="optionsCheckboxs"]:checked');

	$.each(val1, function (i, n) {

		val += $(n).parent().text();
		var2 += $(n).val();
	});

	$("textarea[name=desc]").val(val);
	$("textarea[name=desc]").attr("eut", var2);
}

function binSearchAcrTitle(start, end) {
	var titleList = [];
	var tmp = [];
	var len = g_acrList.length;

	if (len) {
		for (var i in g_acrList) {
			if (start >= g_acrList[i]['first'] && start <= g_acrList[i]['last'] || g_acrList[i]['first'] >= start && g_acrList[i]['last'] <= end || end >= g_acrList[i]['first'] && end <= g_acrList[i]['last']) {
				tmp[g_acrList[i]['title']] = i; // 去重复
			}
		}

		for (var j in tmp) {
			titleList.push(j);
		}

	}
	return titleList;
}

var g_aMutex = 0; // 防止数据不一致
var g_acrList = []; // ocr 识别出的title数据
function getAcr() {
	g_aMutex = 1;
	var tmp = [];
	if (taskid && isStart) {
		$.get(acrUrl, {
			'key' : taskid,
			'index' : 0,
			'type' : 1,
			'from_client' : true
		}, function (data) {

			acr_list = data.list;
			var len = acr_list.length;
			g_acrIndex = len;
			if (len) {
				for (var i in acr_list) {
					if (acr_list[i]['text'] == '' || acr_list[i]['video_list'] == '')
						continue;

					for (var j in acr_list[i]['video_list']) {
						acr_list[i]['video_list'][j] = acr_list[i]['video_list'][j] - 1;
					}

					var tmp2 = [];

					if (acr_list[i]['video_list'].length == 1) {
						tmp2['first'] = tmp2['last'] = acr_list[i]['video_list'].shift();
					} else {
						tmp2['first'] = acr_list[i]['video_list'].shift();
						tmp2['last'] = acr_list[i]['video_list'].pop();

					}
					tmp2['title'] = acr_list[i]['text'];
					tmp.push(tmp2);
				}
			}

			if (tmp != '') {
				if ($("#acr").hasClass("disabled")) {
					$("#acr").removeClass("disabled");
				}

				g_acrList = tmp;
			}
			g_aMutex = 0;
		}, 'json')
	}
}

/* 直转点自动拆条 精细化 */
var VOD = VOD || {
	g_i : 0,
	g_mi : 0
};

VOD.Module = {};

VOD.CONFIG = (function () {
	var _const = {
		sty : 'http://' + ip + ':8080/dot/sty', // 自动拆条
		channel : 'http://lego.iqiyi.com/suggest/operation', // 频道
		album : 'http://lego.iqiyi.com/suggest/album',
		legoProgramIdUrl : 'http://lego.iqiyi.com/peditor/submit', //lego获取programid接口
		//cpUrl : 'http://lego.iqiyi.com/live2VOD/cp/search', // 合作方接口
		cpUrl : 'http://dispatch.live2vod.qiyi.domain/v1/partner/find',  //合作方接口
		codeVersionUrl : 'http://' + ip + ':8080/version', // 编码器版本号
		/*
				专辑入智能库  
				list              打点起始向后+3张，结束向前+3张  
				key 			  实际的taskid   $('#taskid')
				ablumId  		  专辑id
				offset 			  精确化
				channelId		  电视台id
				
				广告入节目库
				list 			  广告列表
				key				  实际的taskid   $('#taskid')
				channelId		  电视台id
				
				/dohead   专辑头
				/doend    专辑尾
				/doad     广告入库
		*/
		
		smartLibrary : 'http://' + ip + ':8080/dot/',
		
		
		PGC : 0,
		UGC : 1,
		adLibHead : 0, // 片头
		adLibTail : 1, // 片尾
		adLib : 2, 	   // 广告
	}

	return function (name) {
		return _const[name]
	};
})();

// 存储开关信息
VOD.DAO = {

	getSty : function () {

		if (VOD.DAO.storageData('ASS') != 'on')
			return;

		$.get(VOD.CONFIG('sty'), {
			'key' : taskid,
			'index' : !VOD.DAO.storageData('sty-index') ? 0 : VOD.DAO.storageData('sty-index'),
			'type' : 1,
			'from_client' : true
		}, function (data) {

			var last = 0;

			$.each(data.list, function (i, n) {

				if (n.video_list.length > 0) {
					for (var i in n.video_list) {
						n.video_list[i] = n.video_list[i] - 1;
					}

					last = n.video_list[n.video_list.length - 1];
					var options = {
						sTime : n.video_list[0],
						eTime : last,
						imageId : n.video_list[0]
					}
					VOD.Util.appendAutoSeg(options);
				}
				VOD.DAO.storageData('sty-index', !VOD.DAO.storageData('sty-index') ? 1 : VOD.DAO.storageData('sty-index') + 1);
			});

		}, 'json')
	},

	storageData : function (name, value) {
		var DSN = $('#storage-data');

		if (!value && !name)
			return '';
		else if (value == undefined)
			return DSN.data(name);
		else
			DSN.data(name, value);
	},

	// 获取合作方信息
	getCooperativePartner : function (options, callback) {
		if (options.channeltype == 'undefined' || options.channelalias == 'undefined' || options.channeltype == '' || options.channelalias == '')
			return '';

		$.get(VOD.CONFIG("cpUrl"), options, function (res) {
			if (res.code == 200) {
				callback.call(this, res.response.data);
			} else {
				console.log("【合作方失败信息】" + res.msg);
			}
		}, 'json');
	},

	//获取奇艺suggest初始数据
	getChannel : function (callback) {
				$("body").click(function () {$('.cn_hide3').hide();});
		$("body").on('input propertychange,input focus', 'input[name=categoryName]', function (e) {
			
			var word = $.trim($(this).val());
			if (!word) {
				$(this).val("");
				$('.cn_hide3').hide();
			}

			$parent = $(this).parent();
			var self = $(this);

		//	if(word){
				$.get(VOD.CONFIG('channel'), {
					'word' : word,
					'size' : 50
				}, function (item) {
					if (item.code == 'A00000') {
						var messages = item.data,
						html = "";
						if (messages.length) {
							$.each(messages, function (index, message) {
								html += '<p class="spe" onclick="VOD.Util.setChannel(this,\'' + message.id + '\',\'' + message.name + '\')" id="' + message.id + '" style=margin:0px;padding-bottom:5px;cursor:pointer">' + message.name + '</p>';
							})
							$parent.find('.cn_hide3').html(html).show();
						} else {
							 
							$(this).val("");
							$(this).find("input[name$=categoryId]").val("");
							$parent.find('.cn_hide3').html('<span style="color:red" onclick="$(this).parent().hide();">此频道不存在</span>').show();
							//$parent.find('.cn_hide3').hide();
							VOD.Util.setCooperativePartner("");
							console.log("此频道不存在！");
						}
					}
				}, 'json')
	//		}
		});
	},

	//奇艺专辑suggest接口
	getAlbum : function () {

		$("body").on('input propertychange', 'input[name=albumName],.albumName', function () {
			if (error.length) {
				$(this).val("");
				return false;
			}
			var word = $(this).val();
			if (!word) {
				$(this).val("");
				$("input[name=albumId]").val("");
				$('.cn_hide2').hide();
			}
			var categoryName = $("input[name=categoryName]").val();
			var categoryId = $("input[name=categoryId]").val();
			if (!categoryName || !categoryId){
				$(this).val("");
				$("input[name=categoryName]").val("");
				$("input[name=categroyId]").val("");
				$("input[name=albumId]").val("");
				$('.cn_hide2').hide();
				$(this).attr("disabled","disabled"); 
			}

			$parent = $(this).parent();

			var self = $(this);

			if (word) {
				$.get(VOD.CONFIG('album'), {
					'word' : word,
					'type' : 'displayName',
					'filter_EQL_channel' : categoryId
				}, function (item) {
					$parent.find('.cn_hide2').empty();
					if (item.code == 'A00000') {
						var messages = item.data;
						if (messages.length) {
							$.each(messages, function (index, message) {

								//if(self.hasClass('albumName'))
								var ahtml = '<p class="spe" onclick="VOD.Util.put_input2(this,\'' + message.entityId + '\',\'' + message.displayName + '\')" style="margin:0px;padding-bottom:5px;cursor:pointer">' + message.displayName + '</p>';
								//else
								//var ahtml = '<p class="spe" onclick="put_input(\''+message.entityId+'\',\''+message.displayName+'\')" style="margin:0px;padding-bottom:5px;cursor:pointer">'+ message.displayName +'</p>';

								$parent.find('.cn_hide2').append(ahtml);
							})
							$parent.find('.cn_hide2').show();
						} else {

							$(this).val("");
							$parent.find('.cn_hide2').hide();
						}
					}
				}, 'json')
			}

		});

	},

	// postData(subData,newPA,pic,programId,dataSubmit)
	postDotData : function (options, callback) {
		sList = '[';
		$.each(options.subData, function (k, v) {
			sList += v + ',';
		})
		sList = sList.substring(0, sList.length - 1); //去除逗号
		sList += ']';

		pData = {
			'title' : options.videoName,
			'categoryId' : options.categoryId,
			'albumId' : options.albumId,
			'code' : channel_name,
			'programId' : programId,
			'userId' : $('#userId').text(),
			'from_client' : true,
			'key' : options.taskid,
			'list' : sList,
			'imageId' : options.imageId,
			'head' : accurateFrame.head,
			'end' : accurateFrame.end,
			'uid' : newPA.uid,
			'partnerId' : newPA.partnerId,
			'episodeType' : newPA.episodeType,

		};

		accurateFrame.head = '';
		accurateFrame.end = '';
		accurateFrame.endSetted = false;
		accurateFrame.headSetted = false;		
		
		$.ajax({
			cache : false,
			async : false,
			type : "post",
			url : dotUrl,
			data : pData,
			success : function (data) {

				callback.call(this, data);

			},
			dataType : "json",
			error : function () {
				//alert('编码服务器网络错误,请稍后再提交故事号【' + options.id + '】！');
				live.tips("error",'编码服务器网络错误,请稍后再提交故事号【' + options.id + '】！');
			}
		});
		return true;
	},

	getProgramId : function (options, callback) {
		$.ajax({
			cache : false,
			async : false,
			type : "post",
			url : VOD.CONFIG('legoProgramIdUrl'),
			data : {
				'data' : JSON.stringify(options)
			},
			success : function (res) {

				callback.call(this, res);

			},
			dataType : "json",
			error : function () {
				//alert('网络错误,请稍后再提交故事号【' + options.id + '】！');
				live.tips("error",'网络错误,请稍后再提交故事号【' + options.id + '】！');
			}
		});
	},
	getCodeVersion : function (options) {
		$.ajax({
			cache : false,
			async : false,
			type : "get",
			url : VOD.CONFIG('codeVersionUrl'),
			data : {
				'data' : JSON.stringify(options)
			},
			success : function (data) {
				VOD.DAO.storageData('coderVersion', data);
			},
			error : function () {
				console.log('请求编码器版本号失败,请稍后再试！');
			}
		});
	},
	
	// 入广告智能库
	saveAdLibrary : function (options, callback) {
		options.from_client=true;  //绕过鉴权
		$.ajax({
			cache : false,
			async : false,
			type : "post",
			url : VOD.CONFIG('smartLibrary')+'doad',
			data : options,
			success : function (res) {
				callback.call(this, res);
			},
			dataType : "json",
			error : function () {
				//alert('网络错误,请稍后再入广告智能库！');
				live.tips("error",'网络错误,请稍后再入广告智能库！');
			}
		});
	},	
	
	// 专辑入智能库
	saveAlbumLibrary : function (options, callback) {
		options.from_client=true;
		
		var  head = options.list.head,
			 end = options.list.end,
			 aHead = options.offset.head,
			 aEnd = options.offset.end;
		
		options.list = head;
		options.offset = aHead;
	
		$.ajax({
			cache : false,
			async : false,
			type : "post",
			url : VOD.CONFIG('smartLibrary')+'dohead',
			data : options,
			success : function (res) {
					options.list = end;
					options.offset = aEnd;	
					
					$.ajax({
						cache : false,
						async : false,
						type : "post",
						url : VOD.CONFIG('smartLibrary')+'doend',
						data : options,
						success : function (res) {

							callback.call(this, res);

						},
						dataType : "json",
						error : function () {
							//alert('网络错误,请稍后再入广告智能库！');
							live.tips("error",'网络错误,请稍后再入广告智能库！');
						}
					});				
				

			},
			dataType : "json",
			error : function () {
				//alert('网络错误,请稍后再专辑入智能库！');
				live.tips("error",'网络错误,请稍后再专辑入智能库！');
			}
		});
	},	

};

// 相关初始化动作
VOD.Init = function () {

	var browser = VOD.Util.getUserAgent();
	VOD.Util.detectBrowserSupport(browser);
	$(window).unbind("keydown").bind("keydown", function (e) {
		keyEvent(e);
	});
	VOD.Util.LayoutInit();

	window.onresize = function () {
		VOD.Util.browserZoomTips();
		VOD.Util.LayoutInit();
	};

	VOD.Util.autoSegmentationTabOptions({});

	VOD.DAO.storageData('ASS', 'off'); // 自动拆条开关
	VOD.DAO.storageData('BCS', 'off'); // 背景颜色开关
	VOD.DAO.getChannel(); // 获取频道
	VOD.DAO.getAlbum();
	VOD.DAO.getCodeVersion({});

	VOD.ResetDefaultsBehaviour();

	VOD.Evt.segInputAddBackgroundColor();
	VOD.Evt.segInputScroll();
	VOD.Evt.segInputBlur();
	VOD.Evt.InitBindEvt();

	VOD.Util.browserZoomTips();
	$("body").show();
};

// 重置默认行为
VOD.ResetDefaultsBehaviour = function () {
	// 阻止默认行为
	$('body [href^=#]').click(function (e) {
		e.preventDefault();
	});

	Date.prototype.format = function (format) {
		var o = {
			"M+" : this.getMonth() + 1, //month
			"d+" : this.getDate(), //day
			"h+" : this.getHours(), //hour
			"m+" : this.getMinutes(), //minute
			"s+" : this.getSeconds(), //second
			"q+" : Math.floor((this.getMonth() + 3) / 3), //quarter
			"S" : this.getMilliseconds() //millisecond
		}

		if (/(y+)/.test(format)) {
			format = format.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
		}

		for (var k in o) {
			if (new RegExp("(" + k + ")").test(format)) {
				format = format.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k] : ("00" + o[k]).substr(("" + o[k]).length));
			}
		}
		return format;
	};

};

VOD.Tpl = {

	AutoSegTpl : function (options) {
		var tpl = '<tr>'
			 + '  <td >'
			 + '	<table class="inner-table">'
			 + '		<tr>'
			 + '			<td rowspan="2" style="width:40px;">'
			 + '			<input type="checkbox" name="id" value="{{id}}" style="width:15px;margin:0;padding:0;" action-name="checked-seg-id"/>'
			 + '			<span class="cblue">{{id}}.</span>'
			 + '			</td>'
			 + '			<td><span>入点</span><input type="text" value="{{sTime}}" name="auto.sTime"/></td>'
			 + '			<td><span>出点</span><input type="text" value="{{eTime}}" name="auto.eTime"/></td>'
			 + '			<td><span>封面</span><input type="text" value="{{imageId}}" name="auto.imageId"/></td>'
			 + '			<td><span>频道</span><span class="select-container"><select class="cate" style="" name="auto.categoryId">{{channel}}</select></span></td>' //<input type="text" value="9"/>
			 + '			<td style="position:relative"><span>专辑</span><input type="text" class="albumName" name="auto.albumName" />'

			 + '	<input type="hidden" name="auto.albumId" />'
			 + '  <div class="cn_hide2 album-pop"></div>'

			 + '</td>'
			 + '		</tr>'
			 + '		<tr class="modify-space">'
			 + '			<td colspan="3"><span>标题</span><input type="text" style="width:221px;" value="" name="auto.videoName"/><input value="" type="hidden" name="videoId"/></td>'
			 + '			<td colspan="3" style="text-align:right;"><a class="cblue"  href="javascript:;" action-name="sub-seg">提交拆条</a><a style="margin-left:15px;" class="cred"  href="javascript:;" action-name="sub-ad">提交广告</a></td>'
			 + '		</tr>'
			 + '	</table>'
			 + '	 </td>'
			 + '</tr>';

		return tpl.replace(/{{((?:(?!}})[\s\S])+)}}/g, function (k, key) {
			return options[key] || "";
		});
	},
	MergeSegTpl : function (options) {
		var tpl = '<tr>'
			 + '    <td >'
			 + '	<table class="inner-table">'
			 + '		<tr>'
			 + '			<td rowspan="3" style="vertical-align:top;width:20px;">'
			 + '				<span class="cblue">{{id}}.</span>'
			 + '				</td>'
			 + '			<td colspan="4"><span>合并范围</span><input type="text" style="width:376px;" value="{{range}}"/><input type="hidden" value="{{mergData}}" name="merg.mergData" />'
			 + '<input type="hidden" value="{{sTime}}" name="merg.sTime"/><input type="hidden" value="{{eTime}}" name="merg.eTime"/></td>'
			 + '		</tr>'
			 + '		<tr class="modify-space">'
			 + '			<td><span>封面</span><input type="text" name="merg.imageId" value="{{imageId}}"/></td>'
			 + '			<td><span>频道</span><span class="select-container"><select class="cate" style="" data-id="{{sTime}}" name="merg.categoryId">{{channel}}</select></span></td>'
			 + '			<td style="position:relative"><span>专辑</span><input type="text"  class="albumName" value="{{albumName}}" name="merg.albumName" />'

			 + '	<input type="hidden" value="{{albumId}}" name="merg.albumId" />'
			 + '  <div class="cn_hide2 album-pop"></div>'

			 + '</td>'
			 + '			<td><span>标题</span><input type="text" name="auto.videoName" value="{{videoName}}" style="width:139px;"/></td>'
			 + '		</tr>'
			 + '		<tr class="modify-space">'
			 + '			<td colspan="4" class="cblue"><a href="javascript:;" action-name="sub-seg">提交拆条</a><a  href="javascript:;" style="margin-left:20px" action-name="sub-ad" class="cred">提交广告</a></td>'
			 + '		</tr>'
			 + '	</table>'
			 + '	 </td>'
			 + '</tr>';
		return tpl.replace(/{{((?:(?!}})[\s\S])+)}}/g, function (k, key) {
			return options[key] || "";
		});
	},
	RegularTimeRemindTpl : function () {
		return '<form class="form-horizontal" role="form">'
		 + '  <div class="form-group">'
		 + '	<label class="col-sm-2 control-label">提醒时间</label>'
		 + '	<div class="col-sm-10">'
		 + '	  <input type="text" class="form-control" id="alert-time">'
		 + '	</div>'
		 + '  </div>'
		 + '  <div class="form-group">'
		 + '  <label class="col-sm-2 control-label">提醒方式</label>'
		 + '	<div class="col-sm-3">'
		 + '	  <div class="checkbox">'
		 + '		<label>'
		 + '		   <input type="checkbox" disabled name="blinking" checked>浏览器闪烁'
		 + '		</label>'
		 + '	  </div>'
		 + '	</div>'
		 + '	<div class="col-sm-3">'
		 + '	  <div class="checkbox">'
		 + '		<label>'
		 + '		  <input type="checkbox" disabled name="autdo">声音提示'
		 + '		</label>'
		 + '	  </div>'
		 + '	</div>'
		 + '  </div>'
		 + '</form>';
	},

	HelpTpl : function () {
		var data = [
			["点击 + F 键", "打开始帧"],
			["点击 + D 键", "打结束帧"],
			["点击 + S 键", "打视频封面"],
			["点击 + A 键", "提交打点"],
			["点击 + V 键", "打删除的开始帧"],
			["点击 + C 键", "打删除的结束帧"],
			["点击 + Z 键", "提交删除"],
			["点击 + Q 键", "片头、片尾精确化裁剪"],
			["点击 + W 键", "时间片预览"],
			["R 键", "标题OCR"],
			["X 键", "拆条列表"],
			["上、下、左、右方向键", "上、下、左、右切换"]
		];

		var html = '<table class="table table-striped"><thead><tr><th>快捷键</th><th>快捷键含义</th></tr></thead><tbody>';

		for (var i = 0; i < data.length; i++) {
			html += '<tr><td>' + data[i][0] + '</td><td>' + data[i][1] + '</td></tr>';
		}

		if (VOD.DAO.storageData('coderVersion') == undefined) {
			VOD.DAO.storageData('coderVersion', '0 | 0 | 0');
		}

		html += '</tbody></table><span>版本 V3.2.2 | ' + VOD.DAO.storageData('coderVersion') + '</span>';

		return html;
	},

	// 拆分条广告列表
	adListTpl : function (options) {
		var tpl = '<tr class="scorll-to-frame" frame-index="{{index}}"><td>'
			 + '{{index}}</td>'
			 + '<td>{{sTime}}</td>'
			 + '<td>{{eTime}}</td>'
			 + '<td><div style="padding:0;margin:0;width:124px;overflow:hidden;white-space: nowrap;" title="{{videoName}}">{{videoName}}</div></td>'
			 + '<td>已生成</td>'
			 + '<td><button class="btn btn-info btn-sm" id="del-{{index}}" onclick="if( confirm(\'确认要删除吗?\')){$(this).parent().parent().remove();delOne(\'删除\',\'{{sTime}}\',\'{{eTime}}\');}">删除</button>'
			 + '<a style="margin-left:5px;" onClick="reviewOne(\'{{sTime}}\',\'{{eTime}}\',\'删除\');" class="btn btn-success btn-sm">预览</a><a style="margin-left:5px;" onClick="fromLIstJump(\'{{sTime}}\');" class="btn btn-success btn-sm">跳转</a>'
			 + '</td></tr>';

		return tpl.replace(/{{((?:(?!}})[\s\S])+)}}/g, function (k, key) {
			return options[key] || "";
		});
	},

	// 拆分条拆条列表
	seqListTpl : function (options) {
		var tpl = '<tr class="scorll-to-frame" frame-index="{{index}}"><td>'
			 + '{{index}}</td>'
			 + '<td>{{sTime}}</td>'
			 + '<td>{{eTime}}</td>'
			 + '<td><div style="padding:0;margin:0;width:124px;overflow:hidden;white-space: nowrap;" title="{{videoName}}">{{videoName}}</div></td>'
			 + '<td>{{categoryId}}</td>'
			 + '<td>{{albumName}}</td>'
			 + '<td><div style="padding:0;margin:0;width:75px;overflow:hidden;white-space: nowrap;" title="{{imageId}}">{{imageId}}</div></td>'
			 + '<td>已生成</td>'
			 + '<td><button class="btn btn-info btn-sm" id="del-{{index}}" onclick="if( confirm(\'确认要删除吗?\')){$(this).parent().parent().remove();delOne(\'打点\',\'{{sTime}}\',\'{{eTime}}\');}">删除</button>'
			 + '<a style="margin-left:5px;" onClick="reviewOne(\'{{sTime}}\',\'{{eTime}}\',\'打点\');" class="btn btn-success btn-sm">预览</a><a style="margin-left:5px;" onClick="fromLIstJump(\'{{sTime}}\');" class="btn btn-success btn-sm">跳转</a>'
			 + '</td></tr>';
		return tpl.replace(/{{((?:(?!}})[\s\S])+)}}/g, function (k, key) {
			return options[key] || "";
		});
	},
};

VOD.Util = {

	// 页面布局初始化
	LayoutInit : function () {
		$(".tab-content").css({
			height : VOD.Util.getPageRelativeMesurement().height - 300 - 10 - 39 - 20 - 2
		});
		$("#makedImg").css({
			height : VOD.Util.getPageRelativeMesurement().height - 90 - 20 - 2
		});
	},

	browserZoomTips : function () {

		if (VOD.Util.detectZoom() > 100) {
			$('[role="alert"]').html('您当前浏览器处于放大状态,按<strong>ctrl+0</strong>使用体验更佳!').show();
		} else if (VOD.Util.detectZoom() < 100) {
			$('[role="alert"]').html('您当前浏览器处于缩小状态,按<strong>ctrl+0</strong>使用体验更佳!').show();
		};
	},
	
	dl_click:function(clt){
		try
		{
			if(clt=='')
			{
				return;
			}

			var Then = new Date();

			var continued_time  = Math.round((Then.getTime())/1000);	

			$.get(clt+"&ct="+continued_time);
		}
		catch(e)
		{
		}
	},	
	
	// 填加自动拆条
	appendAutoSeg : function (options) {
		if (VOD.DAO.storageData('ASS') == 'on') {
			var defaults = {
				id : ++VOD.g_i,
				sTime : '',
				eTime : '',
				imageId : ''
			};

			options = $.extend({}, defaults, options);

			if (VOD.DAO.storageData('alternative') == 999) {
				VOD.DAO.storageData('alternative', 'fff');
				VOD.Util.addBackgroundColor({
					st : options.sTime,
					et : options.eTime,
					color : 'c999'
				});
			} else {
				VOD.DAO.storageData('alternative', 999);
				VOD.Util.addBackgroundColor({
					st : options.sTime,
					et : options.eTime,
					color : 'cfff'
				});
			}

			//options.number=options.id;

			options.desc = '入点';
			options.position = 'p-l';
			options.number = options.sTime;
			VOD.Util.addInOutMark(options);

			options.desc = '出点';
			options.position = 'p-r';
			options.number = options.eTime;
			VOD.Util.addInOutMark(options);

			// 背景颜色关闭时去除背景色
			if (VOD.DAO.storageData('BCS') == 'off') {
				$('.fragment-img').addClass('c000');
				$('.in-out-mark-s').hide();
			}

			options.channel = VOD.DAO.storageData('cate-str');
			$('#tab2>table>tbody').append(VOD.Tpl.AutoSegTpl(options));

			$('.auto-seg-tips').hide();
		}

	},

	// 填加合并拆条
	appendMergeSeg : function (options) {
		var defaults = {
			id : ++VOD.g_mi,
			range : '',
			imageId : '',
		};

		options = $.extend({}, defaults, options);

		options.channel = VOD.DAO.storageData('cate-str');
		$('#tab3>table>tbody').append(VOD.Tpl.MergeSegTpl(options));
	},

	// 填加背景色
	addBackgroundColor : function (options) {
		var defaults = {
			st : 0,
			et : 0,
			color : '',
			removeColor : ''
		};
		options = $.extend({}, defaults, options);

		for (i = options.st; i <= options.et; i++) {
			if (!options.removeColor) {
				$('#img-' + i).addClass(options.color);
			} else {
				$('#img-' + i).removeClass(options.color);
			}
		}
	},

	// 填加出入点标识
	addInOutMark : function (options) {

		var bigMark = '';
		if ($("#changeBigPic").hasClass('btn-primary'))
			bigMark = 'in-out-mark-b';

		var str = '<div class="absolute in-out-mark-s ' + bigMark + ' ' + options.position + ' ' + options.position + '-' + options.id + '">' + options.id + '<br>' + options.desc + '</div>';
		$('#img-' + options.number).after(str);

	},

	//  获取页面client相关尺寸
	getPageRelativeMesurement : function () {

		return {
			width : $(window).width(),
			height : $(window).height(),
		};

	},

	// tab标签上自动拆条可用与否
	autoSegmentationTabOptions : function (options) {
		var defaults = {
			name : ''
		};

		options = $.extend({}, defaults, options);

		if (options.name == 'auto-segmentation-tab') {
			$(".nav-opt").find("input").prop("disabled", false);
			$(".nav-opt").find("button").prop("disabled", false).addClass("nav-opt-enable");
		} else {
			$(".nav-opt").find("input").prop("disabled", true);
			$(".nav-opt").find("button").prop("disabled", true).removeClass("nav-opt-enable");
		}

	},

	getUserAgent : function () {
		var ua = navigator.userAgent;

		var result = {
			isStrict : document.compatMode == "CSS1Compat",
			isGecko : /gecko/i.test(ua) && !/like gecko/i.test(ua),
			isWebkit : /webkit/i.test(ua)
		};

		try {
			if (/(\d+\.\d+)/.test(external.max_version)) {
				result.maxthon = +RegExp['\x241'];
			}
		} catch (e) {
			console.log(e);
		}

		if (/msie (\d+\.\d+)/i.test(ua)) {
			result.ie = document.documentMode || +RegExp['\x241'];
		} else if (/trident(\.*?)/i.test(ua)) {
			result.ie = document.documentMode || +RegExp['\x241'];
		} else if (/chrome\/(\d+\.\d+)/i.test(ua)) {
			result.chrome = +RegExp['\x241'];
		} else if (/(\d+\.\d)?(?:\.\d)?\s+safari\/?(\d+\.\d+)?/i.test(ua) && !/chrome/i.test(ua)) {
			result.safari =  + (RegExp['\x241'] || RegExp['\x242']);
		} else if (/firefox\/(\d+\.\d+)/i.test(ua)) {
			result.firefox = +RegExp['\x241'];
		} else if (/opera(?:\/| )(\d+(?:\.\d+)?)(.+?(version\/(\d+(?:\.\d+)?)))?/i.test(ua)) {
			result.opera =  + (RegExp["\x244"] || RegExp["\x241"]);
		}

		return result;
	},

	detectBrowserSupport : function (browser) {
		var support = false;
		// alert(window.ScriptEngineMinorVersion());
		if (browser.isWebkit || browser.firefox) {
			support = true;
		}
		if (browser.ie && browser.ie >= 9) {
			support = true;
		}
		if (!support) {
			var str = '警告！您使用的浏览器版本过低，为了获得更好使用体验。请使用Chrome、Firefox或IE10浏览器。谢谢！';

			//alert(str);
			live.tips("error",str);
		}

	},

	put_input2 : function (self, albumId, albumName) {
		var $this = $(self).parent().parent();
		$this.find("input[name$=albumId]").val(albumId);
		$this.find("input[name$=albumName]").val(albumName);
		$this.find('.cn_hide2').hide();
	},

	// 设置已选择的SUGGEST频道信息
	setChannel : function (self, categoryId, categoryName) {
		var $this = $(self).parent().parent();
		$this.find("input[name=categoryId]").val(categoryId);
		$this.find("input[name=categoryName]").val(categoryName);
		$("input[name=albumName]").removeAttr("disabled");
		$("input[name=albumName]").val("");
		$("input[name=albumId]").val("");
		$this.find('.cn_hide3').hide();
		VOD.Util.setCooperativePartner(categoryName);

	},

	// 加载合作方信息
	setCooperativePartner : function (categoryName) {
		$('#cp').html("");
		var videoTypeMinusOne = isVideoType1();
		if (videoTypeMinusOne) {
			return;
		}
		
		

		// 关联合作方信息
		VOD.DAO.getCooperativePartner({
			'channeltype' : categoryName,
			'channelalias' : channel_name,
			'ptype' : 'UGC',
			'pageNo' : 0,
			'pageSize' : 1000
		}, function (cps) {
			if (cps == undefined){
				return;
			}
			var cpStr = '<option uid="" partnerId="" episodeType="' + VOD.CONFIG("PGC") + '"></option>';
			var i = 0,
			selected = '';

			$.each(cps, function (i, item) {
				if (i++ === 0) {
					selected = "selected";
				} else {
					selected = "";
				}

				cpStr += '<option uid="' + item.ugcid + '" ' + selected + ' partnerId="' + item.qipuid + '" episodeType="' + VOD.CONFIG("UGC") + '">' + item.ugcmsg + '</option>';
			})
			$('#cp').html(cpStr);

		});

	},

	compareTime : function (beginTime, endTime) {

		var beginTimes = beginTime.substring(0, 10).split('-');
		var endTimes = endTime.substring(0, 10).split('-');

		beginTime = beginTimes[1] + '-' + beginTimes[2] + '-' + beginTimes[0] + ' ' + beginTime.substring(10, 19);
		endTime = endTimes[1] + '-' + endTimes[2] + '-' + endTimes[0] + ' ' + endTime.substring(10, 19);

		var a = (Date.parse(endTime) - Date.parse(beginTime)) / 3600 / 1000;
		if (a < 0) {
			return -1;
		} else if (a > 0) {
			return 1;
		} else if (a == 0) {
			return 0;
		} else {
			return 'exception'
		}
	},

	//去除广告数据
	removeAdData : function (stime, etime, needRemoveDelData) {
		stime = parseInt(stime);
		etime = parseInt(etime);
		//subData = [];
		needDatas = [];
		for (i = stime; i <= etime; i++) {
			needDatas.push(i);
		}

		//console.log(needDatas);
		//console.log(delList);
		if (needRemoveDelData && delList.length) {
			$.each(delList, function (k, v) {
				v = parseInt(v);
				if (stime <= v && v <= etime) {
					for (var i = 0; i < needDatas.length; i++) { //删除v的元素
						if (needDatas[i] == v) {
							needDatas.splice(i, 1);
							break;
						}
					}
				}
			})
		}
		return needDatas;
	},

	//去除广告数据
	removeUnselectedData : function (options) {

		needDatas = [];

		if (!options)
			return;

		$.each(options.split(','), function (i, v) {
			var frameNumberArr = v.split('_');
			for (i = parseInt(frameNumberArr[0]); i <= parseInt(frameNumberArr[1]); i++) {
				needDatas.push(i);
			}
		});

		return needDatas;
	},

	addAd2Queue : function (dataSubmit) {
		for (i = parseInt(dataSubmit.sTime); i <= dataSubmit.eTime; i++) {
			delList.push(i);
		}
		uniqueArr = [];
		$.each(delList, function (i, el) { //去重复
			if ($.inArray(el, uniqueArr) === -1)
				uniqueArr.push(el);
		});
		delList = uniqueArr;
	},

	detectZoom : function () {
		var ratio = 0,
		screen = window.screen,
		ua = navigator.userAgent.toLowerCase();

		if (window.devicePixelRatio !== undefined) {
			ratio = window.devicePixelRatio;
		} else if (~ua.indexOf('msie')) {
			if (screen.deviceXDPI && screen.logicalXDPI) {
				ratio = screen.deviceXDPI / screen.logicalXDPI;
			}
		} else if (window.outerWidth !== undefined && window.innerWidth !== undefined) {
			ratio = window.outerWidth / window.innerWidth;
		}

		if (ratio) {
			ratio = Math.round(ratio * 100);
		}

		return ratio;
	}
};

playOneInfo = {};
playOneInfo.mouseenter = false;
VOD.Evt = {

	InitBindEvt : function () {
		// 定时提醒
		$("#alert-pop").bind("click", function () {
			$("#myModalLabel").text("定时提醒");
			$("#radio-title-list").html(VOD.Tpl.RegularTimeRemindTpl());

			$('#alert-time').datetimepicker({
				timeFormat : 'HH:mm:ss',
				stepHour : 1,
				stepMinute : 1,
				stepSecond : 1
			});

			$(".modal-footer").show();
		});

		// 帮助文档
		$("#help-pop").bind("click", function () {
			$("#myModalLabel").text("打点系统帮助");
			$("#radio-title-list").html(VOD.Tpl.HelpTpl());
			$(".modal-footer").hide();
		});

		// 显示小窗口视频预览
		$("#makedImg").on("mouseenter mouseleave", "img",
			function (event) {
			var self = $(this);
			if (event.type == 'mouseenter') {
				playOneInfo.mouseenter = true;
				playOneInfo.left = self.offset().left - $("#play-one").width();
				playOneInfo.top = self.offset().top;
				playOneInfo.time = self.attr("id").split("-")[1];
			} else if (event.type == 'mouseleave') {
				playOneInfo.mouseenter = false;
				$("#play-one").css({
					top : '-1000px',
					left : '-1000px'
				});
			}
		});
	},

	// 显示和隐藏打点打条列表
	ShowAndHideSegmentationList : function () {
		var list = $(".segmentation").find(".list");

		if (list.attr("data-show") == "false") {
			list.show();
			list.attr("data-show", "true");
			$(".title").find(".glyphicon").addClass("glyphicon-chevron-down");
			$('#list-slide-shrink').text('收起');
		} else {
			list.hide();
			list.attr("data-show", "false");
			$(".title").find(".glyphicon").removeClass("glyphicon-chevron-down");
			$('#list-slide-shrink').text('展开');
		}

	},

	// 打开关闭背景颜色
	OpenOrCloseBk : function (self) {
		if (!self.hasClass("switch-position")) {
			self.addClass("switch-position");
			VOD.DAO.storageData('BCS', 'on');
			$('.fragment-img').removeClass('c000');
			$('.in-out-mark-s').show();
		} else {
			self.removeClass("switch-position");
			VOD.DAO.storageData('BCS', 'off');
			$('.fragment-img').addClass('c000');
			$('.in-out-mark-s').hide();

		}
	},

	// 自动拆条
	AutoSegmentate : function (self) {
		if (!self.hasClass("switch-position")) {
			self.addClass("switch-position");
			$('[action-name="switch"]').parent("div").show(); // 背景开关显示
			VOD.DAO.storageData('ASS', 'on'); // 自动拆条开
			VOD.DAO.storageData('BCS', 'on'); // 自动拆条背景色开
		} else {
			self.removeClass("switch-position");
			$('[action-name="switch"]').parent("div").hide();
			VOD.DAO.storageData('ASS', 'off');
		}
	},

	// 禁用与否自动拆条选项
	OpenSegmentationTabOptions : function (options) {
		VOD.Util.autoSegmentationTabOptions(options);
		$('.tab-content').scrollTop(0);
	},

	SelectAll : function (self) {
		if (self.is(':checked'))

			$.each($(".tab-content input[type='checkbox']"), function () {

				if (!$(this).attr('readOnly'))
					$(this).prop('checked', true);

			});
		else
			$(".tab-content input[type='checkbox']").prop('checked', false);
	},
	SubAutoSeg : function (self) {

		VOD.Evt.subSeg(self);

	},
	SubAutoAd : function (self) {

		var $table = self.parents(".inner-table");
		if (self.text() == '提交广告') {
			VOD.Evt.subAd(self);
			return;

		}

		$table.find("input[type='checkbox']").show();
		$table.removeClass("remove-style");
		$table.find(".select-container").removeClass("remove-select-style");
		$table.find("input").removeAttr("readOnly");

		$table.find(".has-sub").remove();
		$table.find("[action-name='sub-seg']").show();
		self.text("提交广告");

	},

	CheckedSegId : function (self) {
		var $tr = self.parents("tr"),
		options = {};

		options.st = $tr.find('[name$="sTime"]').val();
		options.et = $tr.find('[name$="eTime"]').val();
		options.color = "c09f";
		if (!options.st)
			return;

		if (self.is(":checked")) {
			fromLIstJump(options.st);
			VOD.Util.addBackgroundColor(options);
		} else {
			options.removeColor = true;
			VOD.Util.addBackgroundColor(options);
		}

	},

	// 合并已选拆条
	SubAllMerge : function () {
		var merg = {
			range : '',
			imageId : '',
			sTime : '',
			eTime : '',
			albumName : '',
			albumId : '',
			videoName : ''
		},
		$check = $("#tab2").find('[action-name="checked-seg-id"]:checked');
		len = $check.length;

		if (len > 0) {
			var sTime,
			eTime
			mergData = [];

			$.each($check, function (i, item) {

				var $parent = $(this).parents('.inner-table'),
				st = $parent.find('[name$="sTime"]').val(),
				et = $parent.find('[name$="eTime"]').val(),
				seg = '';

				if (!merg.sTime) {
					merg.sTime = st;
					merg.albumName = $parent.find('[name$="albumName"]').val();
					merg.albumId = $parent.find('[name$="albumId"]').val();
					merg.videoName = $parent.find('[name$="videoName"]').val();
					merg.categoryId = $parent.find('[name$="categoryId"]').val();
				}

				eTime = et;

				$(this).trigger('click');

				if (i < len - 1)
					seg = ',';

				merg.range = merg.range + $(this).val() + '(' + st + '-' + et + ')' + seg;
				mergData.push(st + '_' + et);

				if (!merg.imageId)
					merg.imageId = st;
			});

			merg.eTime = eTime;
			merg.mergData = mergData;

			VOD.Util.appendMergeSeg(merg);

			$('[action-name="merge-segmentation-tab"]').trigger('click');
			//console.log(merg);
			$('[data-id="' + merg.sTime + '"]').val(merg.categoryId);

			$('.merg-seg-tips').hide();
		} else
			//alert('请选择要合并项');
			live.tips("error",'请选择要合并项');
	},

	// 删除忆选自动拆条
	SubAllDel : function () {

		var $check = $("#tab2").find('[action-name="checked-seg-id"]:checked'),
		len = $check.length;

		if (len > 0) {
			if (!window.confirm('您确认要删除吗？'))
				return;

			$.each($check, function (i, item) {
				var $parent = $(this).parents('tr');

				$(this).trigger('click');
				//$parent.find('.in-out-mark-s').hide();

				$parent.remove();
			});
		} else
			//alert('请选择要删除项');
			live.tips("error",'请选择要删除项');
	},

	// 提交已选择所有拆条
	SubAllSeg : function () {
		taskid = $('#taskid').html();
		if (!taskid.length) {
			//alert('任务ID为空,不能提交!');
			live.tips("error",'任务ID为空,不能提交!');
			return false;
		}

		var $check = $("#tab2").find('[action-name="checked-seg-id"]:checked'),
		len = $check.length;

		if (len > 0) {
			$.each($check, function (i, item) {
				var $parent = $(this).parents('.inner-table');
				//console.log($(this).val());
				//$(this).trigger('click');
				VOD.Evt.SubAutoSeg($parent.find('[action-name="sub-seg"]'));
			});
		} else
			//alert('请选择要提交的拆条');
			live.tips("error",'请选择要提交的拆条');
	},

	// 提交已选择所有广告
	SubAllAd : function () {
		var $check = $("#tab2").find('[action-name="checked-seg-id"]:checked'),
		len = $check.length;

		if (len > 0) {
			$.each($check, function (i, item) {
				var $parent = $(this).parents('.inner-table');

				$(this).trigger('click');
				VOD.Evt.SubAutoAd($parent.find('[action-name="sub-ad"]'));
			});
		} else
			//alert('请选择要提交的广告');
			live.tips("error",'请选择要提交的广告');
	},

	// 定时提醒
	RegularTimeRemind : function () {
		var regularTime = $("#alert-time").val();

		if (regularTime && regularTime != "undefined") {
			(function () {
				var compareTimeRt = -1, //时间比较结果
				//blinkTimes = 0,     //闪烁次数
				//settedTime = '',
				isTimeArriveInt = null;

				$("#modal-close").trigger('click');
				$("#alert-pop").attr("disabled", "disabled");

				//alert("添加成功");
				live.tips("success",'添加成功');

				var isTimeArrive = function () {
					var time = $("#alert-time").val();
					var now = new Date();
					var nowStr = now.format("yyyy-MM-dd hh:mm:ss");
					compareTimeRt = VOD.Util.compareTime(time, nowStr);
				};

				var titleWink = function () {
					// blinkTimes++;
					//if(blinkTimes==3){blinkTimes=1}

					if (compareTimeRt >= 0) {
						window.focus();
						alert('【' + channel_name + '】【' + regularTime + '】预定时间已到!');
						$("#alert-pop").removeAttr("disabled");
						$("#alert-time").val("");
						clearInterval(isTimeArriveInt);
						return;
					}
					setTimeout(titleWink, 200);
				};

				isTimeArriveInt = setInterval(isTimeArrive, 200);

				//settedTime = time;
				titleWink();

			})();
		} else {
			//alert("时间不能为空");
			live.tips("error",'时间不能为空');
		}
	},

	// 提交自动拆条广告
	subAd : function (self) {

		var options = {},
		notEmpty = {};

		$inputs = self.parents('.inner-table').find('input');

		$.each($inputs, function () {
			var $this = $(this),
			name = $this.attr('name');

			if (name != undefined) {
				name = name.split('.');
				if (name.length > 1)
					name = name[1];
				else
					name = name[0];
				options[name] = $this.val();
			}

		});

		self.parents('.inner-table').find('input[name$=videoName]').val('广告');
		options['videoName'] = '广告';

		var erroNo = '故事号【' + options.id + '】,';

		data = {
			'起始帧' : options.sTime,
			'结束帧' : options.eTime,
			'标题' : options.videoName
		};

		if (isNaN(options.sTime) || !options.sTime) {
			//alert(erroNo + '起始帧有误,必须为数字类型');
			live.tips("error",erroNo + '起始帧有误,必须为数字类型');
			return false;
		}
		if (isNaN(options.eTime) || !options.eTime) {
			//alert(erroNo + '结束帧有误,必须为数字类型');
			live.tips("error",erroNo + '结束帧有误,必须为数字类型');
			return false;
		}
		if (parseInt(options.sTime) > parseInt(options.eTime)) {
			//alert(erroNo + '起始帧不能大于结束帧');
			live.tips("error",erroNo + '起始帧不能大于结束帧');
			return false;
		}

		dataSubmit = {
			'index' : index,
			'sTime' : options.sTime,
			'eTime' : options.eTime,
			'videoName' : options.videoName,
			'channel' : '',
			'album' : '',
			'pic' : ''
		}

		var $table = self.parents(".inner-table");
		if (options.mergData != undefined || options.mergData == '')
			$.each(options.mergData.split(','), function (i, v) {

				var fragmentNumberArr = v.split('_');

				if (fragmentNumberArr.length > 1) {
					dataSubmit.index = index;
					dataSubmit.sTime = fragmentNumberArr[0];
					dataSubmit.eTime = fragmentNumberArr[1];

					VOD.Util.addAd2Queue(dataSubmit);
					$('#showInfo2').append(VOD.Tpl.adListTpl(dataSubmit));
					index++;
				}
			});
		else {
			VOD.Util.addAd2Queue(dataSubmit);
			$('#showInfo2').append(VOD.Tpl.adListTpl(dataSubmit));
		}

		if ($table.find("input[type='checkbox']").is(':checked'))
			$table.find("input[type='checkbox']").trigger('click');

		$table.find("input[type='checkbox']").hide();

		$table.addClass("remove-style");
		$table.find(".select-container").addClass("remove-select-style");
		$table.find("input").attr("readOnly", true);
		$table.find("[action-name='sub-ad']").before("<span class='has-sub' style='color:#666;'>已提交至广告</span>").hide();
		$table.find("[action-name='sub-seg']").hide();

		if (!options.mergData)
			VOD.Util.addBackgroundColor({
				st : options.sTime,
				et : options.eTime,
				color : 'bcred'
			});

		index++;

	},

	// 提交自动拆条
	subSeg : function (self) {
		taskid = $('#taskid').html();
		if (!taskid.length) {
			//alert('任务ID为空,不能提交!');
			live.tips("error",'任务ID为空,不能提交!');
			return false;
		}

		var options = {},
		notEmpty = [];
		options['taskid'] = taskid;

		$inputs = self.parents('.inner-table').find('input');

		$.each($inputs, function () {

			var $this = $(this),
			name = $this.attr('name');

			if (name != undefined) {
				name = name.split('.');
				if (name.length > 1)
					name = name[1];
				else
					name = name[0];
				options[name] = $this.val();
			}

		});

		options['index'] = index;

		options['categoryId'] = self.parents('.inner-table').find('[name$="categoryId"]').val();

		data = {
			'起始帧' : options.sTime,
			'结束帧' : options.eTime,
			'标题' : options.videoName
		};

		dataSubmit = {
			'index' : options.index,
			'sTime' : options.sTime,
			'eTime' : options.eTime,
			'title' : options.videoName,
			'channel' : options.categoryId,
			'album' : options.albumName,
			'pic' : options.imageId
		},

		toLego = true;

		var erroNo = '';

		if (options.id != undefined)
			var erroNo = '故事号【' + options.id + '】,';

		if (isNaN(options.sTime) || !options.sTime) {
			//alert(erroNo + '起始帧有误,必须为数字类型');
			live.tips("error",erroNo + '起始帧有误,必须为数字类型');
			return false;
		}
		if (isNaN(options.eTime) || !options.eTime) {
			//alert(erroNo + '结束帧有误,必须为数字类型');
			live.tips("error",erroNo + '结束帧有误,必须为数字类型');
			return false;
		}
		if (isNaN(options.imageId)) {
			//alert(erroNo + '封面格式有误,必须为数字类型');
			live.tips("error",erroNo + '封面格式有误,必须为数字类型');
			return false;
		}

		if (!options.videoName) {
			//alert(erroNo + '标题不能为空');
			live.tips("error",erroNo + '标题不能为空');
			return false;
		}

		if (parseInt(options.sTime) > parseInt(options.eTime)) {
			//alert(erroNo + '起始帧不能大于结束帧');
			live.tips("error",erroNo + '起始帧不能大于结束帧');
			return false;
		}
		if (parseInt(options.sTime) < 0) {
			//alert(erroNo + '起始帧不能为负数');
			live.tips("error",erroNo + '起始帧不能为负数');
			return false;
		}
		numTime = $('#picNum').text();
		if (parseInt(options.eTime) >= parseInt(numTime)) {
			//alert(erroNo + '结束帧不存在,不能提交');
			live.tips("error",erroNo + '结束帧不存在,不能提交');
			return false;
		}

		if (getMixCharacterLength(options.videoName) > 43) {
			//alert(erroNo + '标题长度不能超过43个字符（一个汉字等于两个字符）');
			live.tips("error",erroNo + '标题长度不能超过43个字符（一个汉字等于两个字符）');
			return false;
		}

		if (!options.imageId) {
			self.parents('.inner-table').find('[name$="imageId"]').val(options.sTime);
			options.imageId = options.sTime;
		}

		//提交数据到乐高
		options.videoId = options.videoId ? options.videoId : 0;

		videotype = -1; //$('input[name=videotype]:checked').val();

		if (videotype == -1) {
			options.videoId = 0;
		}

		//去除广告部分
		options.subData = VOD.Util.removeAdData(options.sTime, options.eTime, true);

		if (options.mergData != undefined) {
			var mergeData = VOD.Util.removeUnselectedData(options.mergData);

			options.subData = $.map(mergeData, function (n) {

					if ($.inArray(n, options.subData) > -1)
						return n;
					else
						return;
				});
		}

		if (!options.subData.length) {
			//alert('该条打了广告，不能再打拆条!');
			live.tips("error",'该条打了广告，不能再打拆条!');
			return false;
		}

		/*
		try{
		if(videonameArr.length){
		var exist=false;
		for(var i in videonameArr){
		if(videonameArr[i]==title){
		exist=true;
		}
		}
		if(!exist){
		alert('提交失败，标题不存在!');
		return false;
		}
		}
		}catch(e){}
		videonameArr=[];
		 */

		var legoOptions = {
			'videoId' : options.videoId,
			'albumName' : options.albumName,
			'videoName' : options.videoName,
			'categoryId' : options.categoryId,
			'albumId' : options.albumId,
			'reTranscodeConfirm' : 1,
			'freeType' : freeType
		}

		VOD.DAO.getProgramId(legoOptions, function (res) {
			//console.log(options);
			if (res.code != 'A00000') {
				//alert(erroNo + '' + res.msg);
				live.tips("error",erroNo + '' + res.msg);
			} else {
				programId = res.data.programId;

				if (!programId) {
					//alert(erroNo + '乐高返回的programId为空!');
					live.tips("error",erroNo + '乐高返回的programId为空!');
					return false;
				}

				VOD.DAO.postDotData(options, function (data) {

					if (data.error != 0) {
						//alert(erroNo + '' + data.error);
						live.tips("error",erroNo + '' + data.error);
					} else {

						var $table = self.parents(".inner-table");

						if ($table.find("input[type='checkbox']").is(':checked'))
							$table.find("input[type='checkbox']").trigger('click');

						$table.find("input[type='checkbox']").hide();

						$table.addClass("remove-style");
						$table.find(".select-container").addClass("remove-select-style");
						$table.find("input").attr("readOnly", true);
						$table.find("[action-name='sub-ad']").before("<span class='has-sub' style='color:#666;'>已提交至拆条</span>").hide();
						self.hide();

						if (!options.mergData)
							VOD.Util.addBackgroundColor({
								st : options.sTime,
								et : options.eTime,
								color : 'bcgreen'
							});

						$('#showInfo1').append(VOD.Tpl.seqListTpl(options));
						index++;
					}

				});
			}

		});
	},

	// 自动拆条input操作时添加背景色
	segInputAddBackgroundColor : function () {
		$('body').on('input propertychange', '.inner-table input', function () {
			var $this = $(this),
			options = {};

			if ($this.attr('name') == 'auto.sTime' || $this.attr('name') == 'auto.eTime') {
				options.st = $this.parents('tr').find('[name="auto.sTime"]').val();
				options.et = $this.parents('tr').find('[name="auto.eTime"]').val();

				options.id = $this.parents('tr').find('[name="id"]').val();

				options.color = 'cfff';
				if ($('#img-' + options.st).hasClass('c999'))
					options.color = 'c999';

				var oldSt = $('.p-l-' + options.id).parent('div').find('.pid').text();
				var oldEt = $('.p-r-' + options.id).parent('div').find('.pid').text();

				// 剔除操作前的背景色
				VOD.Util.addBackgroundColor({
					st : oldSt,
					et : oldEt,
					color : options.color,
					removeColor : true
				});
				// 添加操作后背景色
				VOD.Util.addBackgroundColor(options);
				/*
				VOD.DAO.storageData('old-operate-id',options.id);
				VOD.DAO.storageData('old-operate-options',options);


				if(!VOD.DAO.storageData('old-operate-id')){
				VOD.DAO.storageData('old-operate-id',options.id);
				VOD.DAO.storageData('old-operate-options',options);
				}
				else{
				if(VOD.DAO.storageData('old-operate-id')!=options.id){
				var optionsTmp = VOD.DAO.storageData('old-operate-options');

				optionsTmp.removeColor = true;
				console.log(optionsTmp);
				VOD.Util.addBackgroundColor(optionsTmp);

				VOD.DAO.storageData('old-operate-id',options.id)
				VOD.DAO.storageData('old-operate-options',options);
				}
				}
				 */

				// 添加选中色
				options.color = 'c09f';
				VOD.Util.addBackgroundColor({
					st : oldSt,
					et : oldEt,
					color : options.color,
					removeColor : true
				});
				VOD.Util.addBackgroundColor(options);

				// 清楚左右标示符
				$('.p-l-' + options.id).remove();
				$('.p-r-' + options.id).remove();
				$('.p-l-48-' + options.id).remove();
				$('.p-r-48-' + options.id).remove();

				options.desc = '入点';

				if ($('#img-' + options.st).siblings('div').hasClass('p-l')) {
					options.position = 'p-l-48';
				} else
					options.position = 'p-l';

				options.number = options.st;
				VOD.Util.addInOutMark(options);

				options.desc = '出点';

				if ($('#img-' + options.et).siblings('div').hasClass('p-r'))
					options.position = 'p-r-48';
				else
					options.position = 'p-r';

				options.number = options.et;
				VOD.Util.addInOutMark(options);

			}

		});

	},

	segInputBlur : function (options) {
		$('body').on('blur', '.inner-table input', function () {

			//var optionsTmp = VOD.DAO.storageData('old-operate-options');

			var $this = $(this),
			options = {};

			options.st = $this.parents('tr').find('[name="auto.sTime"]').val();
			options.et = $this.parents('tr').find('[name="auto.eTime"]').val();

			options.removeColor = true;
			options.color = 'c09f';

			if (!$this.parents('tr').find('[name="id"]').is(":checked")) {
				VOD.Util.addBackgroundColor(options);
			}

		});
	},

	//  自动拆条input操作时滚动到相应已标示的拆条
	segInputScroll : function () {
		$('body').on('focus', '.inner-table input', function () {
			var $this = $(this),
			options = {};
			options.st = $this.parents('tr').find('[name="auto.sTime"]').val();
			options.et = $this.parents('tr').find('[name="auto.eTime"]').val();
			options.id = $this.parents('tr').find('[name="id"]').val();
			options.color = 'c09f';

			//VOD.DAO.storageData('old-operate-id',options.id);
			//VOD.DAO.storageData('old-operate-options',options);

			VOD.Util.addBackgroundColor(options);
			if (!options.st)
				return;
			fromLIstJump(options.st);
		});
	},
	// 提交广告智能入库
	saveAdLibrary : function(self){

		taskid = $('#taskid').html();
		if (!taskid.length) {
			//alert('任务ID为空,不能提交!');
			live.tips("error",'任务ID为空,不能提交!');
			return false;
		}		

		var options = {};
		if(delList.length === 0)
		{
			live.tips("error",'广告列表数据不能为空！');
			return false;
		}
		
		options.list = '['+delList.join(',')+']';
		
		options.key = taskid;
		options.channelId = _channel_id;
		options.offsets = adAccurate;  // 广告精确化
		
		if (!options.channelId.length) {
			//alert('频道ID为空,不能提交!');
			live.tips("error",'频道ID为空,不能提交!');
			return false;
		}	
		
		options.ablumId = $('input[name=albumId]').val();
		if (!options.ablumId.length) {
			//alert('专辑ID为空,不能提交!');
			live.tips("error",'专辑ID为空,不能提交!');
			return false;
		}		
				
		VOD.DAO.saveAdLibrary(options,function(data){
			
			if (data.error != 0) {
				//alert(erroNo + '' + data.error);
				live.tips("error","广告入智能库失败！");
				self.removeClass("disabled");
			}
			else
			{
				//alert("广告入智能库提交成功！");
				live.tips("success","广告入智能库提交成功！");
				self.removeClass("disabled");
				//adLibList = [];
			}	
		});
	},
	
	// 提交专辑智能入库
	saveAlbumLibrary : function(self)
	{
		var options = {};

		taskid = $('#taskid').html();
		if (!taskid.length) {
			//alert('任务ID为空,不能提交!');
			live.tips("error",'任务ID为空,不能提交!');
			return false;
		}	

		var sTime = $('input[name=sTime]').val(),
		eTime = $('input[name=eTime]').val();		
		if (isNaN(sTime) || !sTime) {
			//alert('起始帧有误,必须为数字类型');
			live.tips("error",'起始帧有误,必须为数字类型');
			return false;
		}
		if (isNaN(eTime) || !eTime) {
			//alert('结束帧有误,必须为数字类型');
			live.tips("error",'结束帧有误,必须为数字类型');
			return false;
		}		
        
		var acrossTtime = eTime - sTime;
		
		var genList = function(head,end,n)
		{
			var	list = {};
			list.head = [head];
			list.end = [end];
			
			n = n-1;
			
			if(n>=6)
			{
				n = 6;
			}

			for(var i=1;i<=n;i++)
			{
				list.head.push(head+i);
			}
			
			for(var j=1;j<=n;j++)
			{
				list.end.unshift(end-j);
			}			
			
			list.head = '['+list.head.join(',')+']';
			list.end = '['+list.end.join(',')+']';
			
			
			return list;
		}
		
		options.list = genList(parseInt(sTime),parseInt(eTime),acrossTtime);
       				
		options.key = taskid;
		
		options.ablumId = $('input[name=albumId]').val();
		if (!options.ablumId.length) {
			//alert('专辑ID为空,不能提交!');
			live.tips("error",'专辑ID为空,不能提交!');
			return false;
		}
		
		if(!accurateFrame.headSetted)
		{
			accurateFrame.head = 0;
			
			/*
			//alert("请在片头使用精确化裁剪工具，快捷键Q");
			live.tips("error","请在片头使用精确化裁剪工具，快捷键Q");
			return false;
			*/
		}
		
		if(!accurateFrame.endSetted)
		{
			accurateFrame.end = 0;
			/*
			//alert("请在片尾使用精确化裁剪工具，快捷键Q");
			live.tips("error","请在片尾使用精确化裁剪工具，快捷键Q");
			return false;
			*/
		}
		
		options.offset = {'head' : accurateFrame.head,'end' : accurateFrame.end}		
		options.channelId = _channel_id;
		if (!options.channelId.length) {
			//alert('频道ID为空,不能提交!');
			live.tips("error",'频道ID为空,不能提交!');
			return false;
		}			
				
		self.addClass("disabled");
		
		VOD.DAO.saveAlbumLibrary(options,function(data){
			if (data.error != 0) {
				//alert(erroNo + '' + data.error);
				live.tips("error",data.error);
				self.removeClass("disabled");
			}
			else
			{
				//alert("专辑入智能库提交成功！");
				live.tips("success","专辑入智能库提交成功！");
				self.removeClass("disabled");
				/*
				accurateFrame.head = '';
				accurateFrame.end = '';
				accurateFrame.endSetted = false;
				accurateFrame.headSetted = false;	
				$('input[name=sTime]').val(""),
				$('input[name=eTime]').val("");
				*/				
			}
			
		});		
	}
}

!function ($) {

	"use strict"; // jshint ;_;

	$(function () {
		VOD.Init();

		$("body").on('click', '[action-name]', function () {
			var self = $(this),
			name = self.attr('action-name');

			switch (name) {
			case 'segmentation':
				VOD.Evt.ShowAndHideSegmentationList();
				break;
			case 'switch': // 拆条背景颜色打开与关闭
				VOD.Evt.OpenOrCloseBk(self);
				break;
			case 'auto-segmentation': // 自动拆条
				VOD.Evt.AutoSegmentate(self);
				break;
			case 'auto-segmentation-tab': // 自动拆条tab标签上的参数选项禁用与否
				VOD.Evt.OpenSegmentationTabOptions({
					name : 'auto-segmentation-tab'
				});
				break;
			case 'merge-segmentation-tab':
			case 'segmentation-params-tab':
				VOD.Evt.OpenSegmentationTabOptions({
					name : ''
				});
				break;
			case 'select-all':
				VOD.Evt.SelectAll(self);
				break;
			case 'sub-seg':
				VOD.Evt.SubAutoSeg(self);
				break;
			case 'sub-ad':
				VOD.Evt.SubAutoAd(self);
				break;
			case 'checked-seg-id':
				VOD.Evt.CheckedSegId(self);
				break;
			case 'sub-all-seg':
				VOD.Evt.SubAllSeg(self);
				break;
			case 'sub-all-ad':
				VOD.Evt.SubAllAd(self);
				break;
			case 'sub-all-merge':
				VOD.Evt.SubAllMerge(self);
				break;
			case 'sub-all-del':
				VOD.Evt.SubAllDel(self);
				break;
			case 'save-ad-smart-library':
				VOD.Evt.saveAdLibrary(self);
				break;
			case 'save-album-smart-library':
				VOD.Evt.saveAlbumLibrary(self);
				break;				

			default:
				break;
			}

		});
	});

}
(window.jQuery);

var live2vodModApi = "${live2VodListApi}";

</script>
</body>
</html>
